题目1515:打印1到最大的N位数
时间限制:1 秒
内存限制:128 兆
特殊判题:否
提交:2180
解决:1093
-
题目描述:
-
给定一个数字N,打印从1到最大的N位数。
-
输入:
-
每个输入文件仅包含一组测试样例。
对于每个测试案例,输入一个数字N(1<=N<=5)。
-
输出:
-
对应每个测试案例,依次打印从1到最大的N位数。
-
样例输入:
-
1
-
样例输出:
-
1 2 3 4 5 6 7 8 9
#include <stdio.h> int main() { int n; int i; while(scanf("%d",&n)!=EOF) { int max=1; while(n>0) { max=max*10; n--; } for(i=1;i<max;++i) printf("%d\n",i); } return 0; } /************************************************************** Problem: 1515 User: road Language: C Result: Accepted Time:40 ms Memory:912 kb ****************************************************************/