1. 程式人生 > 其它 >我擦,C++列印0-999,只要三行,這麼簡單???

我擦,C++列印0-999,只要三行,這麼簡單???

\(4.2\) 竟然更新了:

\[{\colorbox{Red}{{\colorbox{Orange}{{\colorbox{Gold}{{\colorbox{yellow}{{\colorbox{GreenYellow}{{\colorbox{LimeGreen}{{\colorbox{Turquoise}{{\colorbox{Aquamarine}{{\colorbox{CornflowerBlue}{{\colorbox{Blue}{{\colorbox{BlueViolet}{{\color{white}\colorbox{DarkOrchid}{不開longlong見祖先}}}}}}}}}}}}}}}}}}}}}}}{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{{}_{\color{red}{{\text{}}}\color{black}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} \]

`

先發code,防金針菇
#include <bits/stdc++.h>
#define A(x) x;x;x;x;x;x;x;x;x;x;
long long main() {int n = 0;	A(A(A(printf("%d  ",n++))));}

WHY

先付原陽間程式碼


Shift+Ctrl+a ing~~~~~~~~~~~~~~~~~

#include <bits/stdc++.h>//標頭檔案好評(tao)
using namespace std;//名字空間好評(tao*2)
#define A(x) x;x;x;x;x;x;x;x;x;x;
//NOIP中的define題就是平時授……呃呃呃,跑題了(tao*3)  
int main() {
	long long n = 0;
	A(A(A(printf("%d  ",n++))));  
  /*相當於把printf命令複製貼上1000次,
  然後按照從左往右執行,
  每次n都執行了一次n++操作

	其實就是等於printf("%d  ",n++);
    printf("%d  	",n++);
    printf("%d  ",n++);
    printf("%d  	",n++);
    printf("%d  ",n++);.....*/
    
	return 0;//return 0;好評(tao*4)
/*其實還可以通過增加printf前的括號和大寫A來改變列印的數量,
比如0-99;0-999;0-9999;
0-9999999999999999999999………………………………………………
(差點忘了,要在整型範圍內(tao*5))*/
}

這道題其實是在
https://blog.csdn.net/qq_40969467/article/details/105431440
看到的

(低情商:我怎麼可能想出這方法來)
(高情商:我這麼有這樣的腦子)