}
else if (number
top=mid+1; }
if(!sign||loca==-1)
cout<
if (c=='N'||c=='n') flag=false; }
return 0; } 5.9题
#include
{int sum_day(int,int); int leap(int year);
int year,month,day,days=0;
cout<<\ cin>>year>>month>>day;
cout< days=sum_day(month,day); 函数一 */ if(leap(year) && month>=3) 数二 */ days=days+1; cout<<\ return 0; } int sum_day(int month,int day) //计算日期 {int i; int day_tab[12]={31,28,31,30,31,30,31,31,30,31,30,31}; for (i=0;i } /* 调用/* 调用函 int leap(int year) //判断是否为闰年 {int leap; leap=year%4==0&&year0!=0||year@0==0; return(leap); } 5.10题 #include {int i,j,upper,lower,digit,space,other; char text[3][80]; upper=lower=digit=space=other=0; for (i=0;i<3;i++) {cout<<\ gets(text[i]); for (j=0;j<80 && text[i][j]!='\\0';j++) {if (text[i][j]>='A'&& text[i][j]<='Z') upper++; else if (text[i][j]>='a' && text[i][j]<='z') lower++; else if (text[i][j]>='0' && text[i][j]<='9') digit++; else if (text[i][j]==' ') space++; else other++; } } cout<<\ cout<<\ cout<<\ :\ cout<<\ :\ cout<<\ :\ return 0; } 5.11题 #include { char a[5]={'*','*','*','*','*'}; int i,j,k; char space=' '; for (i=0;i<5;i++) // 输出5行 { cout< cout< cout< cout< 5.11题另一解 #include { string stars=\ int i,j; for (i=0;i<5;i++) // 输出5行 { cout<<\ \ // 每行前面留4个空格 for (j=1;j<=i;j++) cout<<\ // 每行再插入i个空格 cout< 5.12题 #include char ch[80],tran[80]; cout<<\ gets(ch); cout<<\ j=0; while (ch[j]!='\\0') { if ((ch[j]>='A') && (ch[j]<='Z')) tran[j]=155-ch[j]; else if ((ch[j]>='a') && (ch[j]<='z')) tran[j]=219-ch[j]; else tran[j]=ch[j]; j++; } n=j; cout<<\ for (j=0;j char ch[80]; cout<<\ gets(ch); cout<<\ j=0; while (ch[j]!='\\0') { if ((ch[j]>='A') && (ch[j]<='Z')) ch[j]=155-ch[j]; else if ((ch[j]>='a') && (ch[j]<='z')) ch[j]=219-ch[j]; else ch[j]=ch[j]; j++; } n=j; cout<<\ for (j=0;j string ch=\ tran=ch; cout<<\ j=0; while (j<=ch.size()) { if ((ch[j]>='A') && (ch[j]<='Z')) tran[j]=155-ch[j]; else if ((ch[j]>='a') && (ch[j]<='z')) tran[j]=219-ch[j]; else tran[j]=ch[j]; j++; } cout<<\ cout< #include string ch=\ cout<<\ j=0; while (j<=ch.size()) { if ((ch[j]>='A') && (ch[j]<='Z')) ch[j]=155-ch[j]; else if ((ch[j]>='a') && (ch[j]<='z')) ch[j]=219-ch[j]; j++; } cout<<\ cout<