今年NOIP居然"各有兩道題目從NOI題庫中抽取並在原題基礎上改動后使用",不好好刷題怎么行。
01 Hello, World!
根據題意直接輸出 "Hello, World!" 即可。

#include <iostream> using namespace std; int main() { cout<<"Hello, World!"<<endl; return 0; }
02 輸出第二個整數
讀入$a,b,c$,輸出$b$。

#include <iostream> using namespace std; int main() { int a,b,c; cin>>a>>b>>c; cout<<b<<endl; return 0; }
03 對齊輸出
輸出語句應該是 printf("%8d %8d %8d\n",a,b,c); 。

#include <cstdio> using namespace std; int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); printf("%8d %8d %8d\n",a,b,c); return 0; }
04 輸出保留3位小數的浮點數
輸出語句應該是 printf("%.3f\n",x);

#include <cstdio> using namespace std; int main() { double x; scanf("%lf",&x); printf("%.3f\n",x); return 0; }
05 輸出保留12位小數的浮點數
輸出語句應該是 printf("%.12f\n",x); ,並且變量x必須是 double 類型的。

#include <cstdio> using namespace std; int main() { double x; scanf("%lf",&x); printf("%.12f\n",x); return 0; }
06 空格分隔輸出
注意輸入輸出順序。

#include <iostream> #include <cstdio> using namespace std; int main() { char a; int b; float c; double d; cin>>a>>b>>c>>d; printf("%c %d %f %f\n",a,b,c,d); return 0; }
07 輸出浮點數
這個題目向我們展示了 printf("%g\n",x); 這條語句的神奇之處。根據百度,這樣做可以省略所有無意義的0,而 printf("%f\n",x); 會固定輸出6位小數。

#include <cstdio> using namespace std; int main() { double x; scanf("%lf",&x); printf("%f\n%.5f\n%e\n%g\n",x,x,x,x); return 0; }
08 字符三角形
注意每行末無空格。

#include <cstdio> using namespace std; int main() { char c; scanf("%c",&c); printf(" %c\n",c); printf(" %c%c%c\n",c,c,c); printf("%c%c%c%c%c\n",c,c,c,c,c); return 0; }
09 字符菱形
和上題極其相似。

#include <cstdio> using namespace std; int main() { char c; scanf("%c",&c); printf(" %c\n",c); printf(" %c%c%c\n",c,c,c); printf("%c%c%c%c%c\n",c,c,c,c,c); printf(" %c%c%c\n",c,c,c); printf(" %c\n",c); return 0; }
10 超級瑪麗游戲
這題很萌~耐心做就行了。(好吧我沒有原圖,隨便搜了一張)
******** ************ ####....#. #..###.....##.... ###.......###### ### ### ### ### ........... #...# #...# #...# #...# ##*####### #.#.# #.#.# #.#.# #.#.# ####*******###### #.#.# #.#.# #.#.# #.#.# ...#***.****.*###.... #...# #...# #...# #...# ....**********##..... ### ### ### ### ....**** *****.... #### #### ###### ###### ############################################################## ################################## #...#......#.##...#......#.##...#......#.##------------------# #...#......#.##------------------# ###########################################------------------# ###############------------------# #..#....#....##..#....#....##..#....#....##################### #..#....#....##################### ########################################## #----------# ############## #----------# #.....#......##.....#......##.....#......# #----------# #.....#......# #----------# ########################################## #----------# ############## #----------# #.#..#....#..##.#..#....#..##.#..#....#..# #----------# #.#..#....#..# #----------# ########################################## ############ ############## ############ |
![]() |

#include <iostream> using namespace std; int main() { cout<<" ********"<<endl; cout<<" ************"<<endl; cout<<" ####....#."<<endl; cout<<" #..###.....##...."<<endl; cout<<" ###.......###### ### ### ### ###"<<endl; cout<<" ........... #...# #...# #...# #...#"<<endl; cout<<" ##*####### #.#.# #.#.# #.#.# #.#.#"<<endl; cout<<" ####*******###### #.#.# #.#.# #.#.# #.#.#"<<endl; cout<<" ...#***.****.*###.... #...# #...# #...# #...#"<<endl; cout<<" ....**********##..... ### ### ### ###"<<endl; cout<<" ....**** *****...."<<endl; cout<<" #### ####"<<endl; cout<<" ###### ######"<<endl; cout<<"############################################################## ##################################"<<endl; cout<<"#...#......#.##...#......#.##...#......#.##------------------# #...#......#.##------------------#"<<endl; cout<<"###########################################------------------# ###############------------------#"<<endl; cout<<"#..#....#....##..#....#....##..#....#....##################### #..#....#....#####################"<<endl; cout<<"########################################## #----------# ############## #----------#"<<endl; cout<<"#.....#......##.....#......##.....#......# #----------# #.....#......# #----------#"<<endl; cout<<"########################################## #----------# ############## #----------#"<<endl; cout<<"#.#..#....#..##.#..#....#..##.#..#....#..# #----------# #.#..#....#..# #----------#"<<endl; cout<<"########################################## ############ ############## ############"<<endl; return 0; }