首页/ 题库 / [单选题]有以下程序 struct s { int的答案

有以下程序 struct s { int x,y; } data[2]={10,100,20,200}; main() struct s *p=data; printf("%d ",++(p->x)); 程序运行后的输出结果是

单选题
2022-07-11 08:03
A、10
B、11
C、20
D、21
查看答案

正确答案
B

试题解析
解析:本题中定义了一个结构体数组data[2]并初始化,主函数中定义了一个结构体类型指针变量并让它指向data的首地址,由于p指向第一个元素的地址,所以p->x相当于data[0].x即为10,所以++(p->x)后的值为11.所以,4个选项中选项B符合题意。

标签:
感兴趣题目
有以下说明语句:struct point{int x;int y;}p;则正确的赋值语句是()
设有定义:struct{int n;float x;}s[2],m[2]={{10,2.8},{0,0.0}};,则以下赋值语句中正确的是(  )。
有以下程序 #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 ",p->name,p->num); } 程序运行后的输出结果是
有以下程序: #include<stdio.h> struct stu { int num;char name[l0];int age;}; void fun(struct stu*p) { printf("%s ",p->name);} main( ) { struct stu x[3]={{01,"Zhang",20),{02,"Wang",l9},{03,"Zha0",l8}}; fun(x+2); } 程序运行后的输出结果是( )。
以下程序的输出结果是______。#include<stdio.h>struct stu{ int num; char name[10]; int age;};void fun(struct stu*p){ printf("%s ",(*p).name);}main(){ struct stu students[3]={ {9801,"Zhang",20}, { 9802,"Wang",19}, { 9803,"Zhao",18} }; fun(students+2);}
有以下程序: #include<<stdio.h> struct stu { int num; char name[10]: int age;} void fun(struct stu*p) {printf("%s\n",(*p).name);} the main { struct stu students[3]={{9801,"Zhang".20}, {9802,"Wang",19},{9803,"Zhao",1 8}} fun(students+2); } 输出的结果是( )。
有以下程序 struct s { int x,y; } data[2]={10,100,20,200}; main() struct s *p=data; printf("%d ",++(p->x)); 程序运行后的输出结果是
有以下程序: #include <stdio.h> struct s { int x,y;} data[2]={10,100,20,200}; main() { struct s *p=data; printf("%d ",++(p->x)); 程序运行后的输出结果是( )。
若有如下语句: struct a {char x[10] int y; }s,*t; t=&s; 则对结构体变量s中的成员y的正确引用是( )
有以下程序 struct STU { char name[10]; int num; float TotalScore; }; vold f(struct STU *p) { struct STU s[2]={{"SunDan",20044,550),{"Penghua".20045,537}},*q=s ++p; ++q; *p=*q; } main() { struct SrU s[3]={{"YangSan",20041,703),{"LiSiGuo",20042,580}}; f(s); printf("%s %d %3.of ",S[1].name,s[1].num,s[1].Totalscore); } 程序运行后的输出结果是
有以下程序段: typedef struct node(int data;struct node*next;)*NODE; NODE P; 以下叙述中正确的是( )。
有以下程序段 typedef struct node{ int data;struct node *next;}*NODE; NODE p; 以下叙述中正确的是
相关题目
若 x 和y 都是 int 型变量,x=100, y=200,且有下面的程序片段:
printf("%d",(x,y));
上面程序片段的输出结果是
下面程序的输出是( )main(){ struct cmplx{int x;int y;}cnum[2]={1,3,2,7};printf(%d ,cnum[0]y/cnum[0]xcnum[1]x); }
已知int x=10,y=20,z=30;以下语句执行后x,y,z的值是( ) if(x>y) z=x; x=y; y=z;
有以下程序:main(){ int a[]={2,4,6,8,10},y=0,x,p;p=&a[1];for(x=1;x<3;x++) y+=(p+x)printf(“%d\n”,y);}程序运行后的输出结果是 ()
若x和y都是int型变量,x=100,y=200,且有下面的程序片段: printf("%d",(x,y));上面程序片段的输出结果是____
下列程序段执行后x、y和z的值分别是() int x=10,y=20,z=30; if(x>y)z=x;x=y;y=z;
若有以下结构体,则正确的定义或引用的是struct Test{int x;int y;} vl;
若x和y都是int型变量,x=100,y=200,且有程序片段:printf("%d",(x,y)); 上面程序片段的输出结果 ( )
有以下程序: void f(int y,int *x) { y=y+ *x; *x;=*x+y;} main() { int x=2,y=4; f(y,&x); - printf ("%d %d ",x,y); } 执行后的输出结果是 ______。
有以下程序 #include<stdio.h> struct ord { int x,y;} dt[2]={1,2,3,4}; mare() { struct ord*p=dt; printf("%d,",++p->x); printf("%d ",++p->y); } 程序的运行结果是______。
以下程序的输出结果是( )。 int x=10,y=10; printf(“%d %d ”,x--,--y);
设有以下C语言说明语句,则值为210的表达式是(33)。 struct s { int a;int *b;}; Int x0[]={110,120},x1[]={210,220}; struct s x[]={{100},{200}},*p=x; x[0].b=x0;x[1].b=x1;
有以下程序:#include <iostream>using namespace std;class sample{private: int x; static int y;public: sample(int a); static void print(sample s);};sample:: sample(int a){ x=a; y+=x;}void sample:: print(sample s){ cout<<"x="<<s. x<<",y="<<y<<end1;}int sample:: y=0;int main(){ sample s1(10); sample s2(20); sample:: print(s2); return 0;}程序运行后的输出结果是( )。
以下程序的执行后,x和y的值是 ______ 。 #include <iostream. h> class Sample { public: int x; int y; void disp() { cout<<"x="<<x<<", y="<<y<<end1; } }; void main() int Sample: :*pc; Sample s; pc=&Sample:: x; s. *pc=10; pc=&Sample: :y; s. *pc=.20; s. disp ();
有如下程序段#include "stdio.h"typedef union{ long x[2]; int y[4]; char z[8];}atx;typedef struct aa { long x[2]; int y[4]; char z[8];} stx;main(){ printf("union=%d,struct aa=%d\n",sizeof(atx),sizeof(stx));}则程序执行后输出的结果是A.union=8,struct aa=8 B.union=8,struct aa=24C.union=24,struct aa=8 D.union=24,struct aa=24
有以下程序struct S{ int n; int a[20]; }; void f(int *a,int n) {int i; for(i=0;i a[i]+=i; } main() {int i; struct S s={10,{2,3,1,6,8,7,5,4,10,9}}; f(s.a, s.n); for(i=0;i printf(“%d”,s.a[i]); } 程序运行后的输出结果是( )。
有以下程序: struct S{int n;int a[20];}; void f(int*a,int n) {int i; for(i=0;i<n-1;i++)a[i]+=i;} mainf() {int i;struct S s{10,{2,3,1,6,8,7,5,4,10,9}}; if(s.a,s.n); for(i=0;i<s.n;i++)printf("%d",s.a[i]);} 程序运行后的输出结果是( )。
有以下程序 struct S { int n;int a[20];}; void f(int *a,int n) { int i; for(i=0;i<n-1;i++)a[i]+=i; } main() { int i;struct S s={10,{2,3,1,6,8,7,5,4,10,9}}; f(s.a,s.n); for(i=0;i<s.n;i++)printf("%d,",s.a[i]); } 程序运行后的输出结果是
有以下程序:#includestruct S{int a;int *b;};main(){ int x1[] = {3,4},x2[] = {6,7}; struct S x[] = {1,x1,2,x2}; printf(%d,%d,*x[0].b,*x[1].b);}程序的运行结果是(  )。
给出以下程序: SET TALK OFF X=0 Y=0 DO WHILE X<100 X=X+1 IF INT(X/2)=X/2 LOOP ELSE Y=Y+X ENDIF ENDDO ?"Y=",Y RETURN 运行结果为 ______。
广告位招租WX:84302438

免费的网站请分享给朋友吧