阅读程序,分析程序执行结果( )。#define N 20int fun(int a[],int n,int m){ int j;for(j=m;j=n;j--)a[j+1]=a[j];}int main(){ int j,a[N]={1,2,3,4,5,6,7,8,9,10};fun(a,2,9);for(j=0;j5;j++)printf(%d,a[j]);}
A: 10234
B: 12344
C: 12334
D: 12234
A: 10234
B: 12344
C: 12334
D: 12234
举一反三
- 阅读程序,分析程序执行结果( )。 #define N 20 int fun(int a[],int n,int m) { int j;for(j=m;j>=n;j--) a[j+1]=a[j]; }int main() { int j,a[N]={1,2,3,4,5,6,7,8,9,10}; fun(a,2,9); for(j=0;j<5;j++) printf("%d",a[j]); } A: 10234 B: 12344 C: 12334 D: 12234
- 以下程序的运行结果是_______。int fun(int array[3][3]){ int j;for(j=0;j<;3;j++) array[1][j]++;printf("\n");}main(){ int j,a[3][3]={0,1,2,1,0,4,2,4,5};fun(a);for(j=0;j<;3;j++)printf("%2d",a[1][j]);printf("\n");} A: 2 1 5 B: 1 0 4 C: 0 1 2 D: 1 2 3
- 以下程序的运行结果是( )。 void fun(int a[][3], int n) { int j; for(j=0;j A: 1 2 3 B: 2 5 8 C: 3 6 9 D: 7 8 9
- 写出以下程序运行结果。 #include<iomanip.h> const int N=3; int main() { int a[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}}; int b[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}}; int i,j,c[N][N]; for(j=0;j<N;i++) //计算矩阵C for(j=0;j<N;j++) c[i][j]=a[i][j]+b[i][j]; for(j=0;j<N;i++) //输出矩阵C { for(j=0;j<N;j++) cout<<setw(5)<<c[i][j]; cout<<endl; } }[/i][/i][/i][/i]
- 针对如下三个实现矩阵求和的不同函数:int a[N][N];int sumA( int a[N][N] ){ int i, j; int sum = 0; for ( i = 0; i < N; i++ ) for ( j = 0; j < N; j++ ) sum += a[i][j]; return sum;}int sumB( int a[N][N] ){ int i, j; int sum = 0; for ( j = 0; j < N; j++ ) for ( i = 0; i < N; i++ ) sum += a[i][j]; return sum;}int sumC( int a[N][N] ){ int i, j; int sum = 0; for ( j = 0; j < N; j+=2 ) for ( i = 0; i < N; i+=2 ) sum += ( a[i][j] + a[i+1][j] + a[i][j+1] + a[i+1][j+1] ); return sum;}当N足够大的时候,三个函数的运行时间t1、t2、t3符合下列哪种情况?()[/i][/i][/i][/i] A: t1 > t2 > t3 B: t3 > t1 > t2 C: t2 > t3 > t1 D: t3 > t2 > t1