单选题有以下程序#include struct S{ int n; int a[20];};void f(struct S *p){ int i,j,t; for(i=0;in-1;i++)  for(j=i+1;jn;j++)   if(p-a[i]p-a[j])   {    t=p-a[i];    p-a[i]=p-a[j];    p-a[j]=t;   }}main(){ int i; struct S s = {10,{2,3,1,6,8,7,5,4,10,9}}; f(s); for(i=0;iA1,2,3,4,5,6,7,8,9,10,B10,9,8,7,6,5,4,3,2,1,C2,3,1,6,8,7,5,4,10,9,D10,9,8,7,6,1,2,3,4,5,

单选题
有以下程序#include struct S{ int n; int a[20];};void f(struct S *p){ int i,j,t; for(i=0;in-1;i++)  for(j=i+1;jn;j++)   if(p->a[i]>p->a[j])   {    t=p->a[i];    p->a[i]=p->a[j];    p->a[j]=t;   }}main(){ int i; struct S s = {10,{2,3,1,6,8,7,5,4,10,9}}; f(&s); for(i=0;i
A

1,2,3,4,5,6,7,8,9,10,

B

10,9,8,7,6,5,4,3,2,1,

C

2,3,1,6,8,7,5,4,10,9,

D

10,9,8,7,6,1,2,3,4,5,


参考解析

解析:
将结构体变量的地址作为实参传递,函数调用可以修改实参结构体中成员的值。函数f的作用是,把p指向的struct中的数组a的元素按照从小到大的方式排序。答案选择A选项。

相关考题:

34 ) 有以下程序#include stdio.hint f(int n);main(){ int a=3,s;s=f(a);s=s+f(a);printf("%d\n",s);}int f(int n){ static int a=1;n+=a++;return n;}程序运行以后的输出结果是A)7B)8C)9D)10

以下程序的输出结果是includein[fun(int n,int *s){int n,f2;if(n==0‖n==1)*s=1;else{ 以下程序的输出结果是 #include<stdio.h> in[fun(int n,int *s) {int n,f2; if(n==0‖n==1) *s=1; else {fun(n-1,f1); fun(n-2,f2); *s=f1+f2; }} void main() { int x; fun(6,x); pfintf("\n%d",x);}A.7B.13C.9D.10

以下程序的输出结果是【 】。include defineN 5 int fun(int *s,int a,int n) {int j; *s= 以下程序的输出结果是【 】。include <stdio.h>define N 5int fun(int *s,int a,int n){ int j;*s=a j=n;while(a!=s[j]) j-;return j;main(){ int s[N+1]; int k:for(k=1 ;k<=N;k++) s[k]=k+1:print f("%d\n",fun(s,4,N));}

以下程序的输出结果是 include int f( ) { static int i=0; int s=1 s+ =i; 以下程序的输出结果是 #include<iostream.h> int f( ) { static int i=0; int s=1 s+ =i; i++; return s;} void main( ) { int i,a=0; for(i=0 ;i<5;i++)a+=f( ); cout < < a;}A.20B.24C.25D.15

有以下程序includestruct STU{char name[10];int num;};void f(char*name, intnum){s 有以下程序 #include <string.h> struct STU { char name[10]; int num; }; void f(char *name, int num) { struct STU s[2]={{"SunDan",20044},{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() { struct STU s[2]={{"YangSan",20041},{"LiSiGuo",20042}},*p; p=s[1]; f(p->name,p->num); printf("%s %d\n",p->name,p->num); } 程序运行后的输出结果是A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041

有以下程序 include typedef struct { int num;double s; }REC; void funl(REC *x) { x 有以下程序 include<stdio.h> typedef struct { int num;double s; }REC; void funl(REC *x) { x->num=23;x->s=88.5; } void main() { REC a={16,90.0}; fun1(A); printf("%d\n",a.num); } 程序运行后的输出结果是( )。

下面程序的运行结果是[]。include int f(int a[],int n){ if(n>1)return a[0]+f(a+1,n-1 下面程序的运行结果是[ ]。include <stdio.h>int f(int a[],int n){ if(n>1)return a[0]+f(a+1,n-1);elsereturn a[0];}main(){int aa[10]={12,3,4,5,6,7,8,9,10},s;s=f (aa+2,4); printf("%d\n",s); }

有以下程序 include int fun(char s[]) { int n=O; whil 有以下程序 #include <stdio.h> int fun(char s[]) { int n=O; while(*s<='9'*s>='0') { n=10*n+*s-'0'; s++; } return (n); } main() { char s[10]={ '6', '1', '*', '4', '*', '9', '*', '0', '*'}; printf("%d\n",fun(s)); }A.9B.61490C.61D.5

有以下程序:include struet STU{charname[10]; int num; float TotalSeore; };void f( 有以下程序:#include <stdio.h>struet STU{ charname[10]; int num; float TotalSeore; };void f(struet STU * p){ struet STU s [2] = { { "SunDan" ,20044,550 } , { "Penghua" ,20045,537 } } , * q = s; ++p; ++q; *p= *q;}main( ){ struct STU s[3] = { { "YangSan" ,20041,703 }, { "LiSiGuo" ,20042,580} }; f(s) ;printf("% s % d % 3.Of\n" ,s [1]. name, s [1]. num ,s [1]. TotalScore);}程序运行后的输出结果是( )。A.SunDan 20044 550B.Penghua 20045 537C.LiSiGuo 20042 580D.SunDan 20041 703

有以下程序: include struct STU {int num; float TotalScore; 有以下程序: #include <strino.h> struct STU {int num; float TotalScore; }; void f(struct STU p) {struct STU s[2]={{20044,550},{20045,537}}; p.num=s[1].num;p.TotalScore=s[1].TotalScore; } main() {struct STU s[2]={{20041,703},{20042,580}}; f(s[0]); printf("%d%3.0t\n",s[0].num,s[0].TotalScore); } 程序运行后的输出结果是 ______。A.20045 537B.20044 550C.20042 580D.20041 703

有以下程序: include struct STU (char name[10]; int num; }; 有以下程序: #include <string.h> struct STU (char name[10]; int num; }; void f(char *name, int num) {struct STU s[2]={{"SunDan",20044}.{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() {struct STU s[2]={{"YangSall",20041},{"LiSiGao",20042}},*p;p=s[1]; f(p->name,p->num); printf("%s%d\n",p->name,p->num); } 程序运行后的输出结果是 ______。A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041

有以下程序 include void fun(int n, int *p) { int f1,t2; if(n==1 | 有以下程序 #include <stdio.h> void fun(int n, int *p) { int f1,t2; if(n==1 ||n==2) *p=1; else { fun(n-1,f1); fun(n-2,f2); *p=f1+f2; } } main() { int s; fun(3,s); printf("%d\n", s ); }A.2B.3C.4D.5

下列程序的运行结果为【】。 include include {int a; char b[10]; double c;}; 下列程序的运行结果为【 】。include<stdio.h>include<string.h>{ int a; char b[10]; double c; };void f (struct A *t);main(){ struct A a={1001,"ZhangDa",1098.0};f(a) ; printf("%d,%s,%6.lf\n",a.a,a.b,a.C);}void f(struct A*t){ strcpy(t->b, "ChangRong");}

有以下程序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

有以下程序includeincludevoidfun(char*s[],intn){char*t;int i,j;for(i=0 有以下程序 #include <stdio.h> #include <string.h> void fun(char *s[],int n) { char *t; int i,j; for(i=0;i<n-1;++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])) {t=s[i];s[i];s[j];s[j]=t;} } main() { char *ss[]={"bccA.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc

有以下程序:includeint a=2;int f(int *a){return (*a) ++;}main(){ int s=0;{ int a= 有以下程序: #include <stdio.h> int a=2; int f(int *a) { return (*a) ++;} main() { int s=0; { int a=5; s+=f(a); } s+=f(a); printf("%d\n",s) } 执行后的输出结果是( )。A.10B.9C.7D.8

有下列程序: include void fun(int * s,int n1,int n2) { int i,j, 有下列程序: #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},k; fun(a,0,3); fun(a,4,9);fun(a,0,9); for(k=0;k<10;k++)printf("%d",a[k]);printf("\n"); } 程序的运行结果是( )。A.987654321B.4321098765C.5678901234D.987651234

以下程序的输出结果是()。includeint fun(int n,int *s){ int f1,f2;if(n==0||n==1)*s= 以下程序的输出结果是( )。 #include<stdio.h> int fun(int n,int *s) { int f1,f2; if(n==0||n==1) *s=1; else { fun(n-1,f1); fun(n-2,f2); *s=f1+f2; } } void main() { int x; fun(6,x); printf("\n%d" ,x);}A.7B.13C.9D.10

有以下程序:include using namespace std;int s=0;class sample{ static int n;publi 有以下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample (int i) { n=i; } static void add() { s+=n; } }; int sample::n=0;A.2B.5C.7D.3

有以下程序:includeint f(int t[],int n);main(){int a[4]={1,2,3,4},s;s=f(a,2);prin 有以下程序: #include<stdio.h> int f(int t[],int n); main() {int a[4]={1,2,3,4},s; s=f(a,2);printf("%d\n",s); } int f(int t[],int n) {if((n>0)(n<5))return t[n+1]+f(t,n-1); else return 0; } 程序运行后的输出结果是( )。A.4B.7C.10D.61

有以下程序:includeinclude"string.h"void fun(char*s[],int n){char*t;int i,j;for( 有以下程序: #include<stdio.h> #include"string.h" void fun(char*s[],int n) { char*t;int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strlen(s[i])>strlen(s[j])){t=s[i];s[i]=s[j];s[j]=t;} } main() { char*ss[]={"bee","bbcc","xy","aaaacc","aabcc"}; fun(ss,5);printf("%s,%s\n",ss[0],ss[4]); } 程序的运行结果是( )。A.xy,aaaaccB.aaaacc,xyC.bcc,aabccD.aabcc,bcc

有以下程序:include using namespace std;class sample{private:int n;public:sample 有以下程序: #include <iostream> using namespace std; class sample { private: int n; public: sample(){} sample(int m) { n=m; } void addvalue(int m) { sample s; s.n=n+m; *this=s; } void disp () { cout<<"n="<<n<<endl; } }; int main() { sample s (10); s.addvalue(5); s.disp(); return 0; } 程序运行后的输出结果是A.n=10B.n=5C.n=15D.n=20

有以下程序:struct S{int n;int a[20];};void f(struct S*P){int i,j,t;for(i=0;in-1;i++)fo 有以下程序: struct S{int n;int a[20];}; void f(struct S*P) { int i,j,t; for(i=0;i<P->n-1;i++) for(j=j+1;j<P->n-1;j++) if(p->a[i]>p->a[j]) {t=P->a[i];p->a[i]=P->a[j];p->a[j]=t} } main() {int i;struct S s{10,{2,3,1,6,8,7,5,4,10,9}}; f(&s); for(i=0;i<s.n;i++)printf("%d",s.a[i]);} 程序运行后的输出结果是( )。A.3B.4C.5D.6

有以下程序 include int fun(char s[ ]) { int n=0; while(*s='0 有以下程序#include <stdio.h>int fun(char s[ ]){ int n=0;while(*s<='9'*s>='0') {n=10*n+*s-'0';s++;}retum(n);}main( ){ char s[10]={'6','1','*','4','*','9','*','0','*'};printf("%d\n",fun(s));}程序的运行结果是A.9B.61490C.61D.5

以下程序的输出结果是______。includestruct stu{int num; char name[10]; int age;};v 以下程序的输出结果是______。#include<stdio.h>struct stu{ int num; char name[10]; int age;};void fun(struct stu*p){ printf("%s\n",(*p).name);}main(){ struct stu students[3]={ {9801,"Zhang",20}, { 9802,"Wang",19}, { 9803,"Zhao",18} }; fun(students+2);}A.ZhangB.ZhaoC.WangD.18

有以下程序:include include struet STU{ int nam;float TotalSeore;};v 有以下程序:#include <stdio, h>#include <string, h>struet STU{ int nam; float TotalSeore;};void f( strnct STU p){ struct STU s[2] = { {20044,550} ,{20045,537} }; p.num = s [1]. num; p.TotalScore = s [1]. TotalScore;main( ){ struct STU s[2] = {{20041,703} ,{20042,580}}; f(s[0] ); printf( "%d %3.Of\n" ,s[0].num,s[0].TotalSeore); }程序运行后的输出结果是( )。A.20045 537B.20044 550C.20042 580D.20041 703

有以下程序:includeinclude struct STU {char name[10];int hum;};void f( 有以下程序:#include <stdio.h>#include <strine.h> struct STU { char name[10]; int hum;};void f(char * name,iht num){ struct STU s[2] = {{ "SunDan" ,20044} , {" Penghua" ,20045}}; num= s[0]. nnm; strepy(name,s[0], name);}main( ){ struct STU s[2] = {{"YangSan" ,20041 }, { "LiSiGao" ,20042}}, * P; p = s[1]; f(p->name,p->hum); printf("% s %d \n" ,p-> name,p->num);}程序运行后的输出结果是( )。A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041

单选题有以下程序:#include int f(int n);main(){ int a=3,s; s=f(a); s=s+f(a); printf(%d,s);}int f(int n){ static int a=1; n+=a++; return n;}程序运行以后的输出结果是(  )。A7B8C9D10