标签:switch sharp main 试验 div load arp mat .com
#include<iostream> using namespace std; int main() {char choice,c; while(1) {cout <<"menu:A(dd) D(elete) S(ort) Q(uit), select one:"; cin>>c; choice=toupper(c); if(choice==‘A‘) {cout<<"数据已经增加."<<endl; continue;} else if(choice==‘D‘) {cout<<"数据已经删除."<<endl; continue;} else if(choice==‘S‘) {cout<<"数据已经排序."<<endl; continue;} else if(choice==‘Q‘) break; } return 0; }
#include<iostream> using namespace std; int main() {char x; while(true) {cout<<"menu: A(dd) D(elste) S(ort) Q(uit),Select one:"<<endl; cin>>x; switch(x){ case ‘A‘: {cout<<"数据已经增加"<< endl;continue;} case ‘D‘: {cout<<"数据已经删除"<< endl;continue;} case ‘S‘: {cout<<"数据已经排序"<< endl;continue;} case ‘Q‘: break; } break; } return 0; }
#include<iostream> #include<math.h> using namespace std; int main() {int i=2,j,n=0; while(i<=100) {j=2; while(j<=sqrt(i)) {if(i%j==0) break; j++; } if(j>=sqrt(i)) {cout<<i<<"\t"; n++; } if(n%5==0&&n!=0) {n=0; cout<<endl; } i++; } return 0; }
#include<iostream> #include<math.h> using namespace std; int main() {int i=2,j,n=0; do{j=2; do{if(i%j==0) break; j++; }while(j<=sqrt(i)); if(j>=sqrt(i)) {cout<<i<<"\t"; n++; } if(n%5==0&&n!=0) {n=0; cout<<endl; } i++; }while(i<=99); return 0; }
#include<iostream> #include<math.h> using namespace std; int main() {int i,j,n=0; for(i=2;i<=100;i++) {j=2; for(j=2;j<=sqrt(i);j++) {if(i%j==0) break; } if(j>=sqrt(i)) {cout<<i<<"\t"; n++; } if(n%5==0&&n!=0) {n=0; cout<<endl; } } return 0; }
#include<iostream> #include<cstdlib> #include<ctime> using namespace std; int main() {int a,b; srand(time(0)); a=rand()%100; cout<<"请输入一个数(1-100): "; cin>>b; while (true) {if (a<b) {cout<<"你输入的数大了"<<endl; cin>>b; } else if (a>b) {cout<<"你输入的数小了"<<endl; cin>>b; } else {cout<<"你猜对了"<<endl; break; } } return 0; }
#include<iostream> #include<cstdlib> #include<ctime> using namespace std; int main() {int a,b; srand(time(0)); a=rand()%100; cout<<"请输入一个数(1-100): "; cin>>b; do {if (a<b) {cout<<"你输入的数太大了"<<endl; cin>>b; } else if (a>b) {cout<<"你输入的数太小了"<<endl; cin>>b; } else {cout<<"你猜对了"<<endl; break; } }while (true); return 0; }
#include<iostream> using namespace std; int main() { int i,j,k,r=0; int c1,c2,c3; cout<<"定义红色为 0,黄色为 1,蓝色为 2,白色为 3,黑色为 4"<<endl; int a[5]={0,1,2,3,4}; for(i=0;i<=4;i++) {c1=a[i]; for(j=i+1;j<=4;j++) {c2=a[j]; for(k=j+1;k<=4;k++) {c3=a[k]; r++; cout<<c1<<c2<<c3<<endl;} c2=a[j]; } c1=a[i]; } cout<<"一共有"<<r<<"种取法"<<endl; return 0; }
标签:switch sharp main 试验 div load arp mat .com
原文地址:https://www.cnblogs.com/wsggwsc/p/10561281.html