以下程序片段的运行结果是_________。 int x1=30,x2=40; sub(int x,int y) { x1=x; x=y; y=x1; } int main() { int x3=10,x4=20; sub(x3,x4); sub(x2,x1); printf(“%d,%d,%d,%d\n”,x3,x4,x1,x2); }
举一反三
- 下列程序的输出结果是( ) int x1=30,x2=40; void sub(int x,int y) { x1=x;x=y;y=x1;} int main() { int x3=10,x4=20; sub(x3,x4); sub(x2,x1); printf(“%d,%d,%d,%d”,x3,x4,x1,x2); return 0; }
- 【单选题】#include <stdio.h> int x1 = 30, x2 = 40; void sub(int x, int y) { x1 = x; x = y; y = x1; } int main() { int x3 = 10, x4 = 20; sub(x3, x4); sub(x2, x1); printf(" %d, %d, %d, %d ", x3, x4, x1, x2); return 0; } A. 10, 20, 40, 40 B. 10,40, 40, 40 C. 20, 20, 40, 40 D. 10, 10, 40, 40
- 以下程序的输出结果是( )。main(){ int x=1,y=2; void swap(int x,int y); swap(x,y); printf("x=%d,y=%d\n",x,y);}void swap(int x,int y){ x=3,y=4;} A: x=3,y=4 B: x=1,y=2 C: x=3 y=4 D: x=1 y=2
- int main()执行结果是(){int x=2,y=1; switch(x) { case 1: y=x ; break; case 2: y=-x ; case 3: y=x*3 ; break; case 4: y=4*x; } printf(“%d\n”,y);}
- 继续上题,为了程序编写简洁,要给数据框x中的6列重新命名为x1,x2,x3,x4,x5,x6,应该使用的命令是() A: ColNames(x) <- c("x1","x2","x3","x4","x5","x6") B: Names(x) <- c("x1","x2","x3","x4","x5","x6") C: colnames(x) <- c("x1","x2","x3","x4","x5","x6") D: colname(x) <- c("x1","x2","x3","x4","x5","x6")