>n;for(inti=0;i<3;i++){if(strcm"> >n;for(inti=0;i<3;i++){if(strcm" />
欢迎来到天天文库
浏览记录
ID:55176046
大小:240.00 KB
页数:45页
时间:2020-04-30
《c课后部分复习题答案.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1.☆口令验证:#includeusingnamespacestd;intmain(){charn[10];cout<<"请输入口令:"<>n;for(inti=0;i<3;i++){if(strcmp(n,"welcome")==0){cout<<"口令输入正确!"<>n;}elsecout<<"你是非法用户!"<using
2、namespacestd;intmain(){intm[30];doublesum=0;doubleaverage;intcount=-1;cout<<"请输入要统计的正实数,负数表示结束:";do{count++;cin>>m[count];边输入边统计}while(m[count]>=0);.专业.专注.for(inti=0;i<30;i++){if(m[i]>=0)sum=sum+m[i];}average=sum/count;cout<<"你输入了"<3、endl;return0;}3.插入数组:#includeusingnamespacestd;intmain(){intm[5]={1,3,5,7,9};inta,j,i;cout<<"插入前的数组为:";for(i=0;i<5;i++)cout<>a;for(i=0;i<5;i++){if((a>m[i])&&(a=i;j--)m[j+1]=m[j];m[i+1]=a;}if(a4、]){for(j=4;j>=0;j--)m[j+1]=m[j];m[0]=a;}if(a>m[4]){m[5]=a;}}cout<<"插入a后的数组为:";for(i=0;i<6;i++)cout<usingnamespacestd;intmain(){intm[5]={1,3,5,7,9};inta,j,i;cout<<"插入前的数组为:";for(i=0;i<5;i++)cout<5、";cin>>a;for(i=0;i<5;i++){if(m[i]==a){for(j=i;j<5;j++)m[j]=m[j+1];}}if(i>=5){cout<<"查无此数!"<#include#include6、tring>usingnamespacestd;intmain(){intm=0;inti=0;charch[61]="wearethebest!";chara[61];cout<<"复制后字符串为:";while(ch[i]!=' ')不可忘{a[i]=ch[i];i++;}a[i]=' ';cout<#includeusingnamespacestd;intmain(){intm=0;charch[61]="wearethebest!";chara[61];co7、ut<<"复制后字符串为:";for(inti=0;i#includeusingnamespacestd;intmain(){inta;intb[10];cout<<"请输入一个整数:";cin>>a;inti=0;while(a!=0){b[i]=a%2;a=a/2;i++;}cout<<"转化为二进制输出为:";for(i--;i>=0;i--)cout<8、t<usingnamespa
3、endl;return0;}3.插入数组:#includeusingnamespacestd;intmain(){intm[5]={1,3,5,7,9};inta,j,i;cout<<"插入前的数组为:";for(i=0;i<5;i++)cout<>a;for(i=0;i<5;i++){if((a>m[i])&&(a=i;j--)m[j+1]=m[j];m[i+1]=a;}if(a4、]){for(j=4;j>=0;j--)m[j+1]=m[j];m[0]=a;}if(a>m[4]){m[5]=a;}}cout<<"插入a后的数组为:";for(i=0;i<6;i++)cout<usingnamespacestd;intmain(){intm[5]={1,3,5,7,9};inta,j,i;cout<<"插入前的数组为:";for(i=0;i<5;i++)cout<5、";cin>>a;for(i=0;i<5;i++){if(m[i]==a){for(j=i;j<5;j++)m[j]=m[j+1];}}if(i>=5){cout<<"查无此数!"<#include#include6、tring>usingnamespacestd;intmain(){intm=0;inti=0;charch[61]="wearethebest!";chara[61];cout<<"复制后字符串为:";while(ch[i]!=' ')不可忘{a[i]=ch[i];i++;}a[i]=' ';cout<#includeusingnamespacestd;intmain(){intm=0;charch[61]="wearethebest!";chara[61];co7、ut<<"复制后字符串为:";for(inti=0;i#includeusingnamespacestd;intmain(){inta;intb[10];cout<<"请输入一个整数:";cin>>a;inti=0;while(a!=0){b[i]=a%2;a=a/2;i++;}cout<<"转化为二进制输出为:";for(i--;i>=0;i--)cout<8、t<usingnamespa
4、]){for(j=4;j>=0;j--)m[j+1]=m[j];m[0]=a;}if(a>m[4]){m[5]=a;}}cout<<"插入a后的数组为:";for(i=0;i<6;i++)cout<usingnamespacestd;intmain(){intm[5]={1,3,5,7,9};inta,j,i;cout<<"插入前的数组为:";for(i=0;i<5;i++)cout<5、";cin>>a;for(i=0;i<5;i++){if(m[i]==a){for(j=i;j<5;j++)m[j]=m[j+1];}}if(i>=5){cout<<"查无此数!"<#include#include6、tring>usingnamespacestd;intmain(){intm=0;inti=0;charch[61]="wearethebest!";chara[61];cout<<"复制后字符串为:";while(ch[i]!=' ')不可忘{a[i]=ch[i];i++;}a[i]=' ';cout<#includeusingnamespacestd;intmain(){intm=0;charch[61]="wearethebest!";chara[61];co7、ut<<"复制后字符串为:";for(inti=0;i#includeusingnamespacestd;intmain(){inta;intb[10];cout<<"请输入一个整数:";cin>>a;inti=0;while(a!=0){b[i]=a%2;a=a/2;i++;}cout<<"转化为二进制输出为:";for(i--;i>=0;i--)cout<8、t<usingnamespa
5、";cin>>a;for(i=0;i<5;i++){if(m[i]==a){for(j=i;j<5;j++)m[j]=m[j+1];}}if(i>=5){cout<<"查无此数!"<#include#include6、tring>usingnamespacestd;intmain(){intm=0;inti=0;charch[61]="wearethebest!";chara[61];cout<<"复制后字符串为:";while(ch[i]!=' ')不可忘{a[i]=ch[i];i++;}a[i]=' ';cout<#includeusingnamespacestd;intmain(){intm=0;charch[61]="wearethebest!";chara[61];co7、ut<<"复制后字符串为:";for(inti=0;i#includeusingnamespacestd;intmain(){inta;intb[10];cout<<"请输入一个整数:";cin>>a;inti=0;while(a!=0){b[i]=a%2;a=a/2;i++;}cout<<"转化为二进制输出为:";for(i--;i>=0;i--)cout<8、t<usingnamespa
6、tring>usingnamespacestd;intmain(){intm=0;inti=0;charch[61]="wearethebest!";chara[61];cout<<"复制后字符串为:";while(ch[i]!=' ')不可忘{a[i]=ch[i];i++;}a[i]=' ';cout<#includeusingnamespacestd;intmain(){intm=0;charch[61]="wearethebest!";chara[61];co
7、ut<<"复制后字符串为:";for(inti=0;i#includeusingnamespacestd;intmain(){inta;intb[10];cout<<"请输入一个整数:";cin>>a;inti=0;while(a!=0){b[i]=a%2;a=a/2;i++;}cout<<"转化为二进制输出为:";for(i--;i>=0;i--)cout<8、t<usingnamespa
8、t<usingnamespa
此文档下载收益归作者所有