单选题有以下程序:#include main(){ int m=1,n=2,*p=m,*q=n,*r; r=p;p=q;q=r; printf("%d,%d,%d,%d",m,n,*p,*q);}程序运行后的输出结果是(  )。A1,2,1,2B1,2,2,1C2,1,2,1D2,1,1,2

单选题
有以下程序:#include main(){ int m=1,n=2,*p=&m,*q=&n,*r; r=p;p=q;q=r; printf("%d,%d,%d,%d",m,n,*p,*q);}程序运行后的输出结果是(  )。
A

1,2,1,2

B

1,2,2,1

C

2,1,2,1

D

2,1,1,2


参考解析

解析:
m和n的值不变,输出结果为1,2;指针*p和*q交换了指向的位置,即*p=&n,*q=&m,输出结果分别为2,1。答案选择B选项。

相关考题:

有以下程序#include stdio.hmain(){ int m=1,n=2,*p=m,*q=n,*r;r=p;p=q;q=r;printf("%d,%d,%d,%d\n",m,n,*p,*q);}程序运行后的输出结果是A)1,2,1,2B)1,2,2,1C)2,1,2,1D)2,1,1,2

(27)有以下程序#include stdio.hvoid f(int *p,int *q );main(){ int m=1,n=2,*r=m;f(r,n);printf(“%d,%d”,m,n);}void f(int *p,int *q){p=p+1;*q=*q+1;}程序运行后输出的结果是A)1,3 B)2,3 C)1,4 D)1,2

有以下程序 main() { int a=7,b=8,*p,*q,*r; p=a;q=b; r=p; p=q; q=r; printf("%d,%d,%d,%d\n",*p,*q,a,b) ; } 程序运行后输出结果是A.8,7,8,7B.7,8,7,8C.8,7,7,8D.7,8;8,7

有以下程序 include main() { char p[20]={'a','b','c','d'},q[]="abc",r[] 有以下程序 #include<string.h> main() { char p[20]={'a','b','c','d'},q[]="abc",r[]="abcde"; strcpy(p+strlen(q),r);strcat(p,q); printf("%d%d\n",sizeof(p),strlen(p)); } 程序运行后的输出结果是A.20 9B.9 9C.20 11D.11 11

有以下程序 include main() { char p[20]={'a','b','c','d'},q[]="abc",r[] 有以下程序 #include<string.h> main() { char p[20]={'a','b','c','d'},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",strlen(p)); } 程序运行后的输出结果是A.9B.6C.11D.7

有以下程序:includemain(){char p[20]={'a','b','c','d'),q[]="abc",r[]="abcde"strc 有以下程序: #include<string.h> main() {char p[20]={'a','b','c','d'),q[]="abc",r[]="abcde" strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",sizeof(p)); } 程序运行后的输出结果是( )。A.9B.6C.11D.7

若有以下程序段: include using namespace std; int main() {char*p="abcdefgh",*r;l 若有以下程序段:include <iostream>using namespace std;int main(){char*p="abcdefgh",*r;long*q;q=(long*)p;q++;r=(char*)q;cout<<r<<end1;return 0;}该程序的输出结果是【 】。

设程序如下:includeusing namespace std;int main(){int **p,*q,r=10;q=r;p= int main() { int **p,*q,r=10; q=r; p=q; cout<<**p+1<<end1; return 0; } 以上程序的输出结果是( )A. p的地址B. r的地址C.11D.运行错误

有以下程序: inClude structNODE{ int num; structNODE*next; }; main() {StructN00E 有以下程序:#inClude <stdlib.h>struct NODE{int num;struct NODE *next;};main(){ Struct N00E *p,*q,*r;int sum;0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struct NODE));r=(struct NODE *)malloc(Sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;printf("%d\n",sum);}执行后的输出结果是A.3B.4C.5D.6

若有如下程序:include using namespace std;int main(){ char *p="abcdefgh",*r; lon 若有如下程序: #include <iostream> using namespace std; int main() { char *p="abcdefgh",*r; long *q; q=(long *)p; q++; r=(char *)q; cout<<r<<end1; return 0; } 上述程序的输出结果是( )。A.abcdefghB.0C.abcdD.efgh

有以下程序:main(){ int a=7,b=8, *p, *q, *r;p=a; q=b;r=p; p=q; q=r;printf("%d,%d,%d,%d\n", *p,*q,a,b);}程序运行后的输出结果是【 】。

有以下程序: int *f(int *x,int *y) {if(*x<*y)return x; else return y; } main() { int a=7,b=8,*p,*q,*r; p=a; q=b; r=f(p,q); printf("%d,%d,%d\n",*p,*q,*r); } 程序运行后输出结果是______。A.7,8,8B.7,8,7C.8,7,7D.8,7,8

有以下程序: include include struct NODE {int num;struct NODE *next; } 有以下程序:#include <stdio.h>#include <stdlib.h>struct NODE{ int num;struct NODE *next;};main(){ struet NODE *p,*q,*r;int sum=0;p=(struct NODE *) malloc(sizeof(struct NODE));q=(struct NODE *) malloc(sizeof(struet NODE));r=(struct NODE *) malloc(sizeof(struct NODE));P- >num=1;q- >num=2;r->num=3;p- >next=q;q- >next=r;r- >next=NULL;sum + =q- >next- >num;sum + =P- >num;printf("%d\n",sum);}执行后的输出结果是( )A.3B.4C.5D.6

有以下程序includevoid f(int *p,int *q);main(){ int m=1,n=2,*r=m;f(r, n 有以下程序 #include<stdio.h> void f(int *p,int *q); main() { int m=1,n=2,*r=m; f(r, n); printf("%d,%d",m,n); } void f(int*p,int*q) {p=p+1; *q=*q+1;) 程序运行后的输出结果是______。A.1,3B.2,3C.1,4D.1,2

有以下程序includestdio.hint*f(int*p,int*q);main( ){int m=1,n=2,*r=m;r=f(r,stdio.hint*f(int*p,int*q);main( ){int m=1,n=2,*r=m;r=f(r,n);printf(”%d\n”,*r);}int-f(int*P,int*q)(return(*p*q)?p:q;)程序运行后的输出结果是______。

若有如下程序段: include using namespace std; int main() {char*p="abcdefgh",*r;l 若有如下程序段:include <iostream>using namespace std;int main(){char *p="abcdefgh",*r;long *q;q=(long *)p;q++;r=(char *)q;cout<<r<<end1;return 0;}该程序的输出结果是______。

有以下程序 include struct NODE {int num;stmct NODE*next;}; main() { struct NODE 有以下程序#include<stdlib.h>struct NODE{ int num;stmct NODE*next;};main(){ struct NODE*p,*q,*r;p=(struct NODE*)malloc(sizeof(struct NODE));q=(struct NODE*)malloc(sizeof(struct NODE));r=(struct NODE*)malloc(sizeof(struct NODE));p->num=10;q->num=20;r->num=30;p->next=q;q->next=r;printf(“%d\n”,p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.40

有以下程序:include main( ) { int a=7,b=8,* p,*q, *r; p=a;q=b; r=p; p= 有以下程序:#include <stdio.h> main( ) { int a=7,b=8,* p,*q, *r; p=a;q=b; r=p; p=q;q=r; printf(" % d,% d,% d,% d \n", * p, * q.a,b);程序运行后的输出结果是( )。A.8,7,8,7B.7,8,7,8C.8,7,7,8D.7,8,8,7

有以下程序: include struct NODE{ int num; struct NODE*next; } main() {structNOD 有以下程序:#include<stdlib.h>struct NODE{int num;struct NODE *next;}main(){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(Struct NODE *)malloc(sizeof(struct NODE));r=(Struct NODE *)malloc(sizeof(struct NODE));p->num=1; q->num=2; r->num=3;p->next=q; q->next=r; r->next=NULL;sum+=q->next->num;sum+=p->num;printf("%d\n",sum);}执行后的输出结果是( )。A.3B.4C.5D.6

有以下程序 include struct NODE{ int num; struct NODE *next;}; main( ) 有以下程序#include <stdlib.h>struct NODE{int num;struct NODE *next;};main( ){ struct NODE *p,*q,*r;int sum=0;p=(struct NODE *)malloc(sizeof(struct NODE));q=(struct NODE *)malloc(sizeof(struct NODE));r=(struct NODE *)malloc(sizeof(struct NODE));p->num=1;q->num=2;r->num=3;p->next=q;q->next=r;r->next=NULL;sum+=q->next->num;sum+=p->num;printf(“%d\n”,sum);}执行后的输出结果是A.3B.4C.5D.6

有以下程序#includestdio.hmain( ){ int m=1,n=2,*P=&m,*q=n,*r;r=P;P=q;q=r;prinff(“%d,%d,%d,%d\n”,m,n,*P,*q);}程序运行后的输出结果是A.1,2,1,2B.1,2,2,lC.2,1,2,1D.2,1,1,2

以下程序的输出结果是include "stdio.h"int *f(int *x,int *y){ if(*x*y) return x; else return y;}main(){ int a=7,b=8, *p,*q,*r ; p=a; q=b; r= f(p,q); printf("%d,%d,%d\n",*p,*q,*r);}

有下列程序: #includestdi0.h voidf(int*P,int*q); voidmain( ) (intm=1,n=2,*r=&m; f(r,&n);printf("%d,%d",m,n); } voidf(int*P,int*q){p=p+1;*q=*q+1;} 程序运行后的输出结果是( )。A.1,3B.2,3C.1,4D.1,2

有以下程序: #includestdio.h main( ) {int m=1,n=2,*p=m,*q=n,*r; r=P;P=q;q=r; printf("%d,%d,%d,%d\n",m,n,*P,*q); } 程序运行后的输出结果是( )。A.1,2,1,2B.1,2,2,1C.2,1,2,1D.2,1,1,2

有以下程序 include gtruet NODE {intnum;struct NODE *next;}; main() {struct NODE 有以下程序#include <stdlib.h>gtruet NODE{ int num; struct NODE *next; };main(){struct NODE *p,*q,*r;p=(struct NODE*)malloc(sizeof (struct NODE));q=(struct NODE*)malloc(sizeof (struct NODE));r=(struct NODE*)malloc(sizeef (struct NODE));p->num=10; q->num=20; r->num=30;p->next=q; q->next-r;printf("%d\n",p->num+q->next->num);}程序运行后的输出结果是A.10B.20C.30D.50

A.2m=n+p+q+rB.2m+1=n+p+q+rC.2m+2=n+p+q+rD.2m-2=n+p+q+r

单选题有以下程序:#include void f(int*p,int*q);main(){ int m=1,n=2,*r=m; f(r,n); printf("%d,%d",m,n);}void f(int*p,int*q){ p=p+1; *q=*q+1;}程序运行后的输出结果是(  )。A1,3B2,3C1,4D1,2