题目内容

根据下面的定义,能打印出字母M的语句是( )。struct person{char name[10];int age;} c[10] = { “John”, 17, “Paul”, 19, “Mary”, 18, “Adam”, 16 };

A. printf(“%c”, c[3].name);
B. printf(“%c”, c[3].name[1]);
C. printf(“%c”, c[2].name[0]);
D. printf(“%c”, c[2].name[1]);

查看答案
更多问题

阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。输入一个字符串,把该字符串的前 3 个字母移到最后,输出变换后的字符串。比如输入“abcdef”,输出为“defabc”。#include #include #define MAXS 10void Shift( char s[] );void GetString( char s[] );int main(){char s[MAXS];GetString(s);Shift(s);printf("%s\n", s);return 0;}void Shift( char s[] ){char str[4];int i;for (i=0; i<3; i++)________;str[i]='\0';for(i=3; s[i]!='\0'; i++)________;s[i-3]= '\0';strcat(s,str);}void GetString( char s[] ){gets(s);}

阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。将字符写入文件:从键盘输入一行字符,写到文件a.txt中。#include #include int main(void){char ch;FILE *fp;if((________) == NULL){printf("Can't Open File!");exit(0);}while((ch = getchar()) != '\n' )________;if(fclose(fp)){printf("Can not close the file!\n");exit(0);}return 0;}

阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。计算输入的两个数的和与差:定义函数sum_diff(float op1, float op2, float *psum, float *pdiff),其中 op1 和 op2 是输入的两个数,*psum 和*pdiff 是计算得出的和与差。#include void sum_diff(float op1, float op2, float *psum, float *pdiff);int main (void){float op1, op2, sum, diff;void sum_diff(float op1, float op2, float *psum, float *pdiff);printf(“input op1 and op2: “);scanf(“%f%f”, &op1, &op2);________;printf(“%f+%f=%f; %f-%f=%f \n”,op1,op2,sum,op1,op2,diff);return 0;}void sum_diff(float op1, float op2, float *psum, float *pdiff){________ = op1 + op2;________= op1 – op2;}

阅读以下程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。已建立学生信息链表(学号存于num域中,姓名存于name域中,成绩存于score域中),下列函数用于遍历链表并显示结点信息。void Print_Stu_Doc(struct stud_node *head){struct stud_node *ptr;if(________){printf("No Records\n");return;}for(ptr=head; ________; ________)printf("%d\t%s\t%d\n ",ptr->num,ptr->name,ptr->score);printf("\n");}

答案查题题库