第九章 使用结构体类型处理组合数据:9.1 结构体变量的定义9.2 结构体数组9.3 结构体指针9.4 用结构体变量和其指针作函数参数9.5 建立动态单链表   9.6 链表的插入和删除操作9.1结构体变量的定义:结构体变量的定义
9.2结构体数组:结构体变量的定义
9.3结构体指针:结构体指针
9.4用结构体变量和其指针作函数参数:用结构体变量和其指针作函数参数
9.5建立动态单链表:建立动态单链表
9.6链表的插入和删除操作:链表的插入和删除操作
9.7使用结构体类型处理组合数据例题讲解(1):使用结构体类型处理组合数据例题讲解(1)
9.8使用结构体类型处理组合数据例题讲解(2):使用结构体类型处理组合数据例题讲解(2)
9.9使用结构体类型处理组合数据例题讲解(3):使用结构体类型处理组合数据例题讲解(3)
9.10使用结构体类型处理组合数据例题讲解(4):使用结构体类型处理组合数据例题讲解(4)
[单选题]#include <stdio.h>
struct ord
{ int x,y;} dt[2]={1,2,3,4};

main( )
{ struct ord *p=dt;
  printf(“%d,”,++p->x);

  printf(“%d”,++p->y);

 }
程序的运行结果是


选项:[1,2 , 3,4, 2,3, 4,1

]
[单选题]有以下程序

  struct S

 { int a,b;} data[2]={10,100,20,200};

 main()

 { struct S p=data[1];

  printf("%d",++(p.a));

 }

 程序运行后的输出结果是


选项:[11, 21, 10, 20]
[单选题]#include <stdio.h>

main()

{ struct STU 

  { char name[9]; 

    char sex;

    double  score[2]; 

  };

 struct STU a={"Zhao",'m',85.0,90.0),b={"Qian",'f',95.0,92.0);

 b=a;

 printf("%s,%c,%2.0f,%2.0f", b.name,b.sex,b.score[0],b.score[1]); 

}

程序的运行结果是 


选项:[Qian,f,95,92

, Qian,m,85,90, Zhao,f,95,92 

, Zhao,m,85,90

]
[单选题]#include <stdio.h>

struct st

{ int x, y;} data[2]={l,10,2,20};


main()

{ struct st *p=data;

  printf("%d,", p->y);

  printf("%d",(++p)->x);

}  

程序的运行结果是


选项:[10,2  , 20,1, 20,2, 10,1 ]
[单选题]下程序运行结果________

#include <stdio.h>
#include <string.h>
struct  A 

{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.1f ”,a.a,a.b,a.c); 

}
void f(struct A *t)
{

 strcpy(t->b, ”ChangRong”); 

}


选项:[1001,ChangRong,1098.0, 1001,”ZhangDa”,1098.0, 1001,"ChangRong",1098.0, 1001,ZhangDa,1098.0]
[单选题]#include <stdio.h> 
typedef struct 
{int num;double s;} REC; 


void fun1(REC x)

{x.num=23;x.s=88.5;} 


main() 
{ REC a={16,90.0}; 
  fun1(a); 
  printf("%d ",a.num); }

上述程序的输出结果为 ________


选项:[23, 16, 90]
[单选题]以下程序运行后的输出结果是 ________
struct NODE 
{ int  num; 

  struct NODE  *next; } 
main()
{ struct NODE s[3],  *p, *q, *r;

  int  sum=0;

  s[0].num=1; s[1].num=2; s[2].num=3;
  s[0].next=s+1; s[1].next=s+2; s[2].next=s;
  p=s; q=p->next; r=q->next;
  sum+=q->next->num;

  sum+=r->next->next->num;
  printf("%d ", sum); 

}


选项:[5, 2, 4, 1]
[单选题]函数fun的功能是统计person所指结构体数组中所有性别(sex)为M的记录的个数存入n中,请填空:

#define  N  3

typedef  struct

{int num;  

 char nam[10]; 

 char sex;}  SS;

int  fun(SS person[])

{int i,n=0;

 for(i=0;i<N;i++)  if(______==’M’ )   n++;

 return n;

}

main()

{SS  W[N]={{1,”AA”,’F’},{2,”BB”,’M’},  {3,”CC”,’M’}};    

 int n;

 n=fun(W); 

 printf(“n=%d ”,n); } 


选项:[person[i].name, person[i], person[i].sex]
[单选题]#include<stdio.h>

#include<string.h>

struct A

{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.1f",a.a,a.b,a.c);

}

void f(struct A t)

{t.a=1002;

 strcpy(t.b,"ChangRong");

 t.c=1202.0;

 }

结果是


选项:[1002,chang Rong,1202.0, 1001,changRong,1098.0, 1002,Zhang Da,1202.0, 1001,zhangDa,1098.0]
[单选题]以下程序运行后的输出结果是________

#include  <stdio.h>

main()

{ char *p; int i;

 p=(char *)malloc(sizeof(char)*20);

 strcpy(p,"welcome");

 for(i=6;i>=0;i--) putchar(*(p+i));

 printf(" -"); free(p);  

}


选项:[welcome, emocle, emoclew, elcome]

温馨提示支付 ¥1.00 元后可查看付费内容,请先翻页预览!
点赞(0) dxwkbang
返回
顶部