[Game]一个代码游戏 输出1-1000
基本要求 : 输出1-1000当然, 由于完成基本要求非常简单.
所以, 有一些提高难度和趣味性的要求.
提高要求 :
1. 不使用循环
2. 不使用循环和递归
大家开开脑洞试试看
#include <stdio.h> struct X { static int i; X() { ++i; printf("%3d ", i); } }; int X::i = 0; int main() { X arr[1000]; return 0; }]算不算前段时刚好看到的
[此贴子已经被作者于2018-6-4 10:28编辑过]
#include<stdio.h> #define a0( i ) i; #define a1( i ) a0(i) a0(i) #define a2( i ) a1(i) a1(i) #define a3( i ) a2(i) a2(i) #define a4( i ) a3(i) a3(i) #define a5( i ) a4(i) a4(i) #define a6( i ) a5(i) a5(i) #define a7( i ) a6(i) a6(i) #define a8( i ) a7(i) a7(i) #define a9( i ) a8(i) a8(i) int main( void ) { unsigned i=0; a9(printf("%-4u",++i)) a8(printf("%-4u",++i)) a7(printf("%-4u",++i)) a6(printf("%-4u",++i)) a5(printf("%-4u",++i)) a3(printf("%-4u",++i)) puts(""); return 0; }
#include<stdio.h> #define a0(A) putchar('0'); A; #define a1(A) putchar('1'); A; #define a2(A) putchar('2'); A; #define a3(A) putchar('3'); A; #define a4(A) putchar('4'); A; #define a5(A) putchar('5'); A; #define a6(A) putchar('6'); A; #define a7(A) putchar('7'); A; #define a8(A) putchar('8'); A; #define a9(A) putchar('9'); A; #define a10( A,B,C ) \ putchar(A);putchar(B); a0(C) \ putchar(A);putchar(B); a1(C) \ putchar(A);putchar(B); a2(C) \ putchar(A);putchar(B); a3(C) \ putchar(A);putchar(B); a4(C) \ putchar(A);putchar(B); a5(C) \ putchar(A);putchar(B); a6(C) \ putchar(A);putchar(B); a7(C) \ putchar(A);putchar(B); a8(C) \ putchar(A);putchar(B); a9(C) \ #define a100( A,B ) \ a10(A,'0',B) \ a10(A,'1',B) \ a10(A,'2',B) \ a10(A,'3',B) \ a10(A,'4',B) \ a10(A,'5',B) \ a10(A,'6',B) \ a10(A,'7',B) \ a10(A,'8',B) \ a10(A,'9',B) \ #define p0 printf(" "); #define p1 printf(" "); #define p2 printf(" "); int main( void ) { a1(p0) a2(p0) a3(p0) a4(p0) a5(p0) a6(p0) a7(p0) a8(p0) a9(p0) a10('\0','1',p1) a10('\0','2',p1) a10('\0','3',p1) a10('\0','4',p1) a10('\0','5',p1) a10('\0','6',p1) a10('\0','7',p1) a10('\0','8',p1) a10('\0','9',p1) a100('1',p2); a100('2',p2); a100('3',p2); a100('4',p2); a100('5',p2); a100('6',p2); a100('7',p2); a100('8',p2); a100('9',p2); puts("1000"); return 0; }
[此贴子已经被作者于2018-6-4 15:26编辑过]