几道C++程序填空题 高手来哦 显示你们的实力的时候到啦~

下面函数是检验输入的字符是大写还是小写或者不是26个字母,请填空。
#include <iostream>
using namespace std;
① ;
fun (char ch)
{ int i;
if((ch>=’a’)&&(ch<=’z’))
i=1;
else { if( ② )
i=2;
else i=3; }
③ ;}
int main( )
{ int i;
cout<<”请输入一个字符:”;
cin>>ch;
i=fun(ch);
if (i==1)
cout<<”是小写字母:”<<ch<<endl;
else if ( ④ )
cout<<”是大写字母:”<<ch<<endl;
else cout<<”是其它字符:”<<ch<<endl;
return 0; }

下面函数是寻找二维数组中每一行的最大值,请填空。
#define N 5
#define M 5
void max (int a[N][M])
{ int i,j,p;
for (i=0;i<N;i++)
{ ① ;
for (j=1;j<M;j++)
if (a[i][p]<a[i][j])
② ;
cout<<i<<”:”<<p<<endl;
}
}

、下面程序是将字符逆序化,请填空。
#include <iostream>
using namespace std;
① ;
int main( )
{ char ch[]=”hello,boy!”;
char c;
int i=0,j=strlen(ch);
for(; ② ;i++,j--)
{ c=ch[i];
③ ;
ch[j-1]=c;
}
cout<<ch;
return 0;
}

下面程序的功能是将矩阵转置,请填空。
#include<iostream>
using namespace std;
#define I 3
#define J 4
void invert(int a[I][J])
{ int i,j;
int b[J][I];
cout<<”array a:”<<endl;
for(i=0;i<I;i++)
{ for(j=0;j<J;j++)
{ cout<<a[i][j]<<” “;
① ;
}
cout<<endl;
}
cout<<”array b:”<<endl;
for(i=0;i<J;i+=)
{ for(j=0;j<I;j++)
cout<<b[i][j]<<” “;
cout<<endl;
}
}
int main()
{ int a[I][J]={{1,2,3,4},{5,6,7,8},{1,3,5,7}};
② ;
return 0;
}

第一题
① char ch // (这个你写的有问题吧?你再好好看看格式,否则fun函数为什么没有类型呢?)
② ch>='A'&&ch<='Z'
③ return i
④ i==2
第二题
① p=0
② p=j
第三题
① #include <string>
② i<j
③ ch[i]=ch[j-1]
第四题
① b[j][i]=a[i][j]
② invert(a)
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答