第一题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. cout<<"Happy 2021!"<<endl; 6. cout<<"Happy 2021!"<<endl; 7. cout<<"Happy 2021!"<<endl; 8. return 0; 9. }
第二题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. cout<<" ********"<<endl; 6. cout<<" ************"<<endl; 7. cout<<" ####....#."<<endl; 8. cout<<" #..###.....##...."<<endl; 9. cout<<" ###.......###### ### ###"<<endl; 10. cout<<" ........... #...# #...#"<<endl; 11. cout<<" ##*####### #.#.# #.#.#"<<endl; 12. cout<<" ####*******###### #.#.# #.#.#"<<endl; 13. cout<<" ...#***.****.*###.... #...# #...#"<<endl; 14. cout<<" ....**********##..... ### ###"<<endl; 15. cout<<" ....**** *****...."<<endl; 16. cout<<" #### ####"<<endl; 17. cout<<" ###### ######"<<endl; 18. return 0; 19. }
第三题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. cout<<" *"<<endl; 6. cout<<" ***"<<endl; 7. cout<<"*****"<<endl; 8. cout<<" ***"<<endl; 9. cout<<" *"<<endl; 10. return 0; 11. }
第四题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. cout<<" * *"<<endl; 6. cout<<" ** *********"<<endl; 7. cout<<" * *"<<endl; 8. cout<<"* * *"<<endl; 9. cout<<" ** * *"<<endl; 10. cout<<" * * *"<<endl; 11. cout<<" * * *"<<endl; 12. cout<<" * * *"<<endl; 13. cout<<" * * *"<<endl; 14. cout<<"*** *"<<endl; 15. cout<<" * * *"<<endl; 16. cout<<" * * *"<<endl; 17. cout<<" * * *"<<endl; 18. cout<<" * * ***"<<endl; 19. cout<<" * *"<<endl; 20. return 0; 21. }
第五题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. cout<<"小时候,"<<endl; 6. cout<<"乡愁是一枚小小的邮票,"<<endl; 7. cout<<"我在这头,"<<endl; 8. cout<<"母亲在那头。"<<endl; 9. cout<<"----选自余光中的《乡愁》"<<endl; 10. return 0; 11. }
第六题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. cout<<"[1] Select crisps"<<endl; 6. cout<<"[2] Select popcorn"<<endl; 7. cout<<"[3] Select chocolate"<<endl; 8. cout<<"[4] Select cola"<<endl; 9. cout<<"[0] Exit"<<endl; 10. return 0; 11. }
第七题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. char x; 6. cin>>x; 7. cout<<(int)x<<endl; 8. return 0; 9. }
第八题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. char x,y; 6. cin>>x; 7. y=x+32; 8. if(x>='A'&&x<='Z') 9. { 10. cout<<y<<","<<(int)y<<endl; 11. } 12. if(!(x>='A'&&x<='Z')) 13. { 14. cout<<"Input Data error!"<<endl; 15. } 16. return 0; 17. }
第九题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. char x,y,z; 6. cin>>x; 7. if(x>='A'&&x<='Z') 8. { 9. y=x+32; 10. cout<<y<<endl; 11. } 12. if(x>='a'&&x<='z') 13. { 14. z=x-32; 15. cout<<z<<endl; 16. } 17. return 0; 18. }
第十题
1. #include <iostream> 2. #include <iomanip> 3. using namespace std; 4. int main() 5. { 6. double d; 7. scanf("%lf", &d); 8. printf("%f\n", d); 9. printf("%.5f\n", d); 10. printf("%e\n", d); 11. printf("%g\n", d); 12. return 0; 13. }
第十一题
1. #include<iostream> 2. using namespace std; 3. int main() 4. { 5. int a,b,c,d,e,f,g; 6. cin>>a>>b; 7. c=a+b; 8. d=a-b; 9. e=a*b; 10. f=a/b; 11. g=a%b; 12. cout<<a<<" + "<<b<<" = "<<c<<endl; 13. cout<<a<<" - "<<b<<" = "<<d<<endl; 14. cout<<a<<" * "<<b<<" = "<<e<<endl; 15. cout<<a<<" / "<<b<<" = "<<f<<endl; 16. cout<<a<<" % "<<b<<" = "<<g<<endl; 17. return 0; 18. }