中国大学MOOC: 下面程序的运行结果是___ 。 #includevoid main(){ int va[10],vb[10],*pa,*pb,i; pa=va; pb=vb; for(i=0; i<3; i++,pa++,pb++) { *pa=i; *pb=2*i; printf(”%d%d”,*pa,*pb); } pa=&va[0]; pb=&vb[0]; for(i=0; i<3; i++) { *pa=*pa+i; *pb=*pb*i; printf(”%d%d”,*pa++,*pb++); }}
举一反三
- voidmain(){inta[10],b'10],*pa,*pb;pa=a;pb=b;for(inti=0;i<3;i++,pa++,pb++){*pa=i;*pb=2*i;}pa=&a[0];pb=&b[0];for(inti=0;i<3;i++){*pa=*pa+i;*pb=*pb+i;cout<<*pa++<<","<<*pb++<<",";}}
- 写出下列程序的执行结果[color=#000000]#include <stdio.h> [/color][color=#000000]int main(void) [/color][color=#000000]{ [/color][color=#000000] int a[10], b[10], *pa, *pb, i; [/color][color=#000000] pa = a; [/color][color=#000000] pb = b; [/color][color=#000000] for( i=0; i<3; i++, pa++, pb++) [/color][color=#000000] { [/color][color=#000000] *pa = i; [/color][color=#000000] *pb = 2*i; [/color][color=#000000] printf(“%d\t%d\n”, *pa, *pb); [/color][color=#000000] } [/color][color=#000000] pa = &a[0]; [/color][color=#000000] pb = &b[0]; [/color][color=#000000] for ( i=0; i<3; i++) [/color][color=#000000] { [/color][color=#000000] *pa = *pa + i; [/color][color=#000000] *pb = *pb + i; [/color][color=#000000] printf(“%d\t%d\n”, *pa++, *pb++); [/color][color=#000000] } [/color][color=#000000][color=#000000] return 0; [/color][/color][color=#000000]} [/color]
- 【填空题】以下程序的输出结果是 。 main() {int a=10,b=20,*pa=&a,*pb=&b,*p; p=pa;pa=pb;pb=p; printf(“%d,%d”,*pa,*pb);}
- voidmain(){inta[10],b'10],*pa,*pb;pa=a;p...<<","<<*pb++<<",";}}
- 中国大学MOOC: 以下程序段的输出是( )。void swap(int *pa, int *pb) { int pt; pt = *pa, *pa = *pb, *pb = *pa;}int main(void){ int x=1, y=2; swap(&x, &y); printf(%d %d, x, y);}