22.
#include <stdio.h>
main()
{
int i, k;
int array[4][2] = {{1,2}, {4,9}, {6}};
for (i=0; i<2; i++)
for (k=0; k<4; k++)
{
printf("%d,", array[k][i]);
}
printf(" ");
}
main()
{
int i, k;
int array[4][2] = {{1,2}, {4,9}, {6}};
for (i=0; i<2; i++)
for (k=0; k<4; k++)
{
printf("%d,", array[k][i]);
}
printf(" ");
}
程序运行后的输出结果是
答案:C
A)1,2,4,9,6,
B)2,9,6,1,4,
C)1,4,6,0,2,9,0,0,
D)2,9,0,0,1,4,6,0,
12.
#include <stdio.h>
void fun( int *s, int n1, int n2 )
{ int i,j,t;
i=n1; j=n2;
while( i<j )
{ t=*(s+i); *(s+i)=*(s+j); *(s+j)=t;
i++; j--;
}
}
main()
{
int a[10] = { 1,2,3,4,5,6,7,8,9,0} ,i, *p = a;
fun( p,0,3 ); fun( p,4,9 ); fun( p,0,9 );
for( i=0; i<10; i++ )printf("%d ", *( a+i ) );
printf(" " );
}
程序运行后的输出结果是
答案:D
A)0 9 8 7 6 5 1 2 3 4
B)4 3 2 1 0 9 8 7 6 5
C)0 9 8 7 6 5 4 3 2 1
D)5 6 7 8 9 0 1 2 3 4