p63 2-28(1)
include
using namespace std;
int main() { cout<<"Menu:A(dd) D(elete) S(ort) Q(uit),Select one:"<<endl; char a='A',d='D',s='S',q='Q',e; cout<<"数据已经"<<endl; while(1) { cin>>e; if(e==a) { cout<<"增加"; continue; } else if(e==d) { cout<<"删除"; continue; } else if(e==s) { cout<<"排序"; continue; } else (e==q); { cout<<"结束"; break; } } return 0; }p63 2-28(2)
include
using namespace std;
int main() { cout<<"Menu:A(dd) D(elete) S(ort) Q(uit),Select one:"<<endl; char a='A',d='D',s='S',q='Q',e; cout<<"数据已经"<<endl; while(1) { cin>>e; switch(e) { case 'A':cout<<"增加";continue; case 'D':cout<<"删除";continue; case 'S':cout<<"排序";continue; case 'Q':cout<<"结束";break; } } return 0; }p63 2-29
include
using namespace std;
int main() { int i,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); }