1
#include<iostream>
using namespace std;int main(){ char n; while(1) { cout<<"Menu:A(dd) D(elete) S(ort) Q(uit),Select one"<<endl; cin>>n; if(n=='A') cout<<"数据已经增加"<<endl; else if(n=='D') cout<<"数据已经删除"<<endl; else if(n=='S') cout<<"数据已经排序"<<endl; else if(n=='Q') break; else cout<<"wrong selection"<<endl; }return 0;}
2
#include<iostream>
using namespace std;int main(){ int n=2; for(n=2;n<=100;n++){ int m=0; for(m=2;m<=n;m++) { if(n%m==0) { break; } } if(n==m) { cout<<n<<endl; }}return 0;}
#include<iostream>
using namespace std;int main(){ int m=2,n=1; cout<<m<<" "; do { int i; for(i=2;i<m;i++) { if(m%i==0) { break; } else if(m%i!=0&&i==m-1) { if(n%5==0) { cout<<endl; } cout<<m<<" "; n++; } } m++; }while(m<=100);
return 0;}
#include<iostream>
using namespace std;int main(){ cout<<"几种颜色:"; int tnumber=0, number=0, i=0, s=0, x=0, k=0; cin>>tnumber; cout<<"几种颜色:"; cin>>number; int sm=tnumber; int st=number; while(st>1){ sm=sm*(tnumber-1); tnumber--; st--;} int xm=1; for(i=1;i<number;i++){ xm=xm*(i+1); } k=sm/xm; cout<<"有"<<k<<"种取法!";}
#include<iostream.h>
void main(){ inti,j,n,m;i=2;do{ m=1;n=i/2;j=2;do{ if(i%j==0){ m=0;break;}j++;}while(j<=n);if(m)cout<<i<<" ";i++;}while(i<101);}