#include <iostream> using namespace std; int main() {char a; cout<<"Menu:A(add) D(elete) S(ort) Q(uit)"<<endl; cin>>a; while(a!=‘Q‘) { if(a==‘A‘) { cout<<"数据已经增加"<<endl;} else if(a=‘D‘) { cout<<"数据已经删除"<<endl;} else if(a=‘S‘) {cout<<"数据已经排序"<<endl;} cin>>a;} return 0; }
#include <iostream> using namespace std; int main() { char a; cout<<"Menu:A(dd) D(elete) S(ort) Q(uit),select one:"<<endl; cin>>a; while(a!=‘Q‘) {switch(a) { case‘A‘:{cout<<"数据已经增加"<<endl;break;} case‘D‘:{cout<<"数据已经删除"<<endl;break;} case‘S‘:{cout<<"数据已经排序"<<endl;break;} } cin>>a; } return 0; }
#include <iostream> using namespace std; int main() {int n,m,i,j; n=2; while(n<=100) {j=1;i=n/2;m=2; while(m<=i) {if(n%m==0) {j=0;break;} m++; } if(j) { cout<<n<<" ";} n++; } }
#include <iostream> using namespace std; int main() {int n,m,i,j; n=2; do {j=1;i=n/2;m=2; while(m<=i) {if(n%m==0) {j=0;break;} m++; } if(j) { cout<<n<<" ";} n++; } while(n<=100); }
#include <iostream> using namespace std; int main() {int n,m,i,j; n=2; for(;n<=100;n++) {j=1;i=n/2;m=2; for(;m<=i;m++) {if(n%m==0) {j=0;break;} m++; } if(j) { cout<<n<<" ";} } }
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() {int m,n; cout<<"输入1~100以内的数:"<<endl; srand((unsigned)time(0)); m=rand()%(100)+1; cin>>n; while(m!=n) {if(m<n) cout<<"The number is bigger."<<endl; if(m>n) cout<<"The number is lower."<<endl; cin>>n; } cout<<"You are right."<<endl; }
#include <ctime> #include <cstdlib> using namespace std; int main() {int m,n; cout<<"输入1~100以内的数:"<<endl; srand((unsigned)time(0)); m=rand()%(100)+1; cin>>n; do {if(m<n) cout<<"The number is bigger."<<endl; if(m>n) cout<<"The number is lower."<<endl; cin>>n; } while(m!=n); cout<<"You are right."<<endl; }
#include <iostream> using namespace std; int main() {int i,j,k,n=0; for(i=1;i<=5;i++) {for(j=i+1;j<=5;j++) {for(k=j+1;k<=5;k++) cout<<i<<j<<k<<endl; } } }
原文:https://www.cnblogs.com/mzx1999/p/10549062.html