已知:typedef struct date { int year; int month; int day; }DATE; typedef struct student { l
A、stu1. birthday. year = 1999;
B、(*pt). birthday. year = 1999;
C、pt -> birthday -> year = 1999;
D、pt -> birthday. year = 1999;
A、stu1. birthday. year = 1999;
B、(*pt). birthday. year = 1999;
C、pt -> birthday -> year = 1999;
D、pt -> birthday. year = 1999;
(A)struct
{char name[20];
int num;
}STUDENT;
(B)struct STUDENT
{char name[20];
int num;
};
(C)typedef struct
{char name[20];
int num;
}STUDENT;
(D)typedef struct STUDENT
{char name[20];
int num;
};
【说明】 某文本文件中保存了若干个日期数据,格式如下(年/月/日): 2005/12/1 2013/2/29 1997/10/11 1980/5/15 .... 但是其中有些日期是非法的,例如2013/2/29是非法日期,闰年(即能被400整除或者能被4整除而不能被100整除的年份)的2月份有29天,2013年不是闰年。现要求将其中自1985/1/1开始、至2010/12/31结束的合法日期挑选出来并输出。 下面的C代码用于完成上述要求。 【C代码】 include typedef struct{ int year, month, day;/* 年,月,日*/ }DATE; int isLeap Year(int y) /*判断y表示的年份是否为闰年,是则返回1,否则返回0*/ { return((y%4==0 && y%100!=0)Il(y%400==0)); } int isLegal(DATE date) /*判断date表示的日期是否合法,是则返回1,否则返回0*/ { int y=date.year,m= date.month,d=date.day; if (y<1985 II y>2010 II m<1 II m>12 II d31) return 0; if((m==4 ll m==6 ll m==9 II m==11)&& (1) ) return 0; If(m==2){ if(isLeap Year(y)&& (2) ) return 1; 。 else if (d>28) return 0; } return 1; } Int Lteq(DATE d1,DATE d2) /*比较日期d1和d2,若d1在d2之前或相同则返回1,否则返回0*/ { Long t1,t2; t1=d1.year*10000+d1.month*100+d1.day; t2=d2.year*10000+d2.month*100+d2.day; if((3) ) return 1; else return 0; } int main() { DATE date,start={1985,1,1},end={2010,12,30}; FILE*fp; fp=fopen(“d.txt”,”r”); If((4) ) return-1; while(!feof(fp)){ if(fscanf(fp,”%d%d%d”,&date.year,&date.month,&date.day)!=3) break; if((5) ) /*判断是否为非法日期 */ continue; if((6) ) /*调用Lteq判断是否在起至日期之间*/ printf(“%d%d%d\n”,date.year,date.month,date.day); } fclose(fp); Return 0; }
int a_int1;
double a_double;
int a_int2;
};
typedef struct
{
a a1;
char y;
} b;
class c
{
double c_double;
b b1;
a a2;
};
输出cout$amp;
A、struct student { char num[5]; int score; }; student stu1,stu2;
B、struct student stu1,stu2; struct student { char num[5]; int score; };
C、struct student { char num[5]; int score=96; }; struct student stu1,stu2;
D、struct student { char num[5]; int score; }; struct student stu1,stu2;
#include "stdio.h"
typedef struct aa
{ int a;
struct aa *next; } M;
void set(M *k,int i,int *b)
{ int j,d=0;
for(j=1;j
{ k[j-1].next=&k[j];
k[j-1].a=b[d++]; }
k[j].a=b[d]; }
main()
{ M k[5],*p;
int d[5]={23,34,45,56,67};
set(k,5,d);
p=k+1;
printf("%d\n",table); }
则下面的表达式在table处,能使程序执行后,打印输出数据45的是
A.p->next->a
B.++p->a
C.(*p).a++
D.p++->a
A、struct student { int num; char name[20]; char sex; int score; } student1,student2;
B、struct { int num; char name[20]; char sex; int score; }student1, student2;
C、struct student { int num; /* 学号 */ char name[20]; /* 姓名 */ char sex; /* 性别 */ int score; /* 成绩 */ }; ...... struct student student1, student2;
D、struct student student1, student2; ...... struct student { int num; /* 学号 */ char name[20]; /* 姓名 */ char sex; /* 性别 */ int score; /* 成绩 */ };
A、用结构体变量做函数参数,是将整个结构体的所有成员的内容传给被调函数,因此在被调函数中对结构体内容的修改不影响原结构体变量。
B、用结构体数组/结构体指针作函数参数的参数传递效率比用结构体变量做函数参数的参数传递效率要高。
C、用结构体数组/结构体指针作函数参数,是复制结构体的首地址给被调函数,因此在被调函数中可以修改结构体指针所指向的结构体的内容。
D、数组和结构体变量都不可以用做函数返回值的类型。
A、enum {no, yes, none}answer; if (answer == yes) { printf("Yes\n"); }
B、enum response{no = -1, yes = 1, none = 0}; enum response answer;
C、answer = yes; printf("%d", answer);
D、answer = "yes"; printf("%s", answer);
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!