#include class A { int a[10]; int n; public: A(int aa[], int nn): n(nn) { for(int i=0; i
举一反三
- 写出程序的运行结果:#include <;stdio.h>;add1(int a[],int n){ int i;for(i=0; i<;n; i++) a[i]++;}main(){int array[]={0,1,2,3,4,5,6,7,8,9};int i;add1(array,10);for (i=0; i<;10; i++)printf("%d ",array[i]);}[/i][/i]
- 以下程序的输出结果是______。#include [stdio.h]int f(int a[ ],int n){ if(n>1)return a[0]+f(&a[1],n-1);else return a[0];}int main(){ int aa[3]={1,2,3},s;s=f(&aa[0],3);printf(“%d\n”,s);return 0; }
- 下面程序的运行结果是______。#include int f(int a[],int n) if(n>1)return a[0]+f(a+1,n-1);elsereturn a[0];main() int aa[10]=1,2,3,4,5,6,7,8,9,10,s;s=f(aa+2,4); printf("%d\n",s);
- 以下程序运行的输出结果是______。 #include<stdio.h> #define M 100 void fun(int m,int *a,int *n) int i,j=0; for(i=1;j<=m;i++) if(i%7==0 ‖ i%11==0) a[j++]=i; *n=j; main( ) int aa[M],n,k; fun(10,aa,&n); for(k=0;k<n;k++) if((k+1)%20==0)printf("\n"); else printf("%4d",aa[k]); printf("\n");
- 针对如下三个实现矩阵求和的不同函数: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