下列函数invert()的功能是:将数组a中n个元素逆序存放;请填空。 #include<ioStream.h> #define N 10
下列函数invert()的功能是:将数组a中n个元素逆序存放;请填空。
#include<ioStream.h>
#define N 10
void invert(int a[],int n)
{ int i=0,j=n-1-i;
while(______)
{int t;
t=a[i]______;a[j]=t;
i++;
______;
}
}
下列函数invert()的功能是:将数组a中n个元素逆序存放;请填空。
#include<ioStream.h>
#define N 10
void invert(int a[],int n)
{ int i=0,j=n-1-i;
while(______)
{int t;
t=a[i]______;a[j]=t;
i++;
______;
}
}
第1题
第2题
第3题
有下列程序: include<stdio.h> yoidfun(int*a.intn)/*fun函数的功能是将a所指数组元素从大到小排序*/ {intt,i’j; for(i=0;i<n-1;j++) for(j=i+1j<nj++) if(a[i]<a[j]){t=a[i];a[i]=a[jl;a[j]=t;} } main() {intc[10]={1,2,3,4,5,6,7,8,9,0),i; fun(c+4,6); for(i=0;i<10;i++)pfintf(%d,,c[i]); printf(\n); } 程序的运行结果是
A.1,2,3,4,9,8,7,6,5,0,
B.0,9,8,7,6,5,1,2,3,4,
C.0,9,8,7,6,5,4,3,2,1,
D.1,2,3,4,5,6,7,8,9,0
第5题
fun(int x,intb[])
{int k=0,r;
do
{r=x%______;
b[k++]=r;
x/=______;
}while(x);
}
第7题
第8题
第9题
请编写函数fun(),该函数的功能是:将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。
例如,若二维数组中的数据为:
W WWW
S S S S
H H H H
则字符串中的内容应是WSHWSHWSHWSH。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<stdio.h>
define M 3
define N 4
void fun(char (*s)[N],char *b)
{
}
main()
{
char a[100],w[M][N]={{ 'W', 'W', 'W', 'W'},
{'S', 'S', 'S', 'S'},{'H', 'H', 'H', 'H'}};
int i,j;
printf("The matrix:\n");
for(i=0;i<M;i++)
{ for(j=0;j<N;j++)
printf("%3c",w[i][j]);
printf("\n");
}
fun(w,a);
printf("The A string:In");
puts(a);
printf("\n\n");
}
第10题
例如,若s所指字符串中的内容为“ABCDEFGl23456”,其中字符A的ASCIl码值为奇数,因此应当删除;字符8的ASCIl码值为偶数,但在数组中的下标为奇数,因此也应当删除;字符2的ASCIl码值为偶数,在数组中的下标也为偶数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是‘&39;246”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序: