1 //c++语言程序设计第二章习题 2 //2-24 3 #include <iostream> 4 using namespace std; 5 int main() 6 { 7 Flag: 8 cout<<"现在正在下雨吗?是(Y)否(N)"<<endl; 9 char c; 10 cin>>c; 11 if(c == 'Y') 12 cout<<"现在正在下雨"<<endl; 13 else if(c == 'N') 14 cout<<"现在没有下雨"<<endl; 15 else 16 goto Flag; 17 return 0; 18 }
1 //c++语言程序设计第二章习题 2 //2-25 3 #include <iostream> 4 using namespace std; 5 int main() 6 { 7 int score; 8 cout<<"你考试考了多少分?(0~100)"<<endl; 9 cin>>score; 10 if(score>=90&&score<=100) 11 cout<<"优"<<endl; 12 if(score>=80&&score<90) 13 cout<<"良"<<endl; 14 if(score>=60&&score<80) 15 cout<<"中"<<endl; 16 if(score>=0&&score<60) 17 cout<<"差"<<endl; 18 return 0; 19 }
1 //c++语言程序设计第二章习题 2 //2-26 3 #include <iostream> 4 using namespace std; 5 int main() 6 { 7 Flag: 8 char c; 9 cout<<"Menu:A(dd)D(elete)S(ort)Q(uit),select one:"<<endl; 10 cin>>c; 11 switch(c) 12 { 13 case 'A':cout<<"数据已经增加"<<endl; 14 break; 15 case 'D':cout<<"数据已经删除"<<endl; 16 break; 17 case 'S':cout<<"数据已经排序"<<endl; 18 break; 19 case 'Q':break; 20 } 21 if(c != 'Q') 22 { 23 goto Flag; 24 } 25 return 0; 26 }
//c++语言程序设计第二章习题 //2-27 #include <iostream> using namespace std; int main() { for(int i = 2;i<=100;i++) { for(int j = 2;j<=i;j++) { if(i%j == 0&&i!=j) break; if(i == j) cout<<i<<"\t"; } } return 0; }
标签:13,cout,int,namespace,score,2023.4,习题,main From: https://www.cnblogs.com/muzhaodi/p/17315500.html