⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 23.txt

📁 last example for C excieses
💻 TXT
字号:
一、程序改错题(20分)。
    下列程序是建立一个包含学生有关数据的单向链表。但该程序有2个错误,错误出现在每个注释行附近,请调试改正。调试改正中,不得改变程序结构,也不得增删语句。
    #define NULL 0
    struct stud
     {
       long  num;
       char name[10];
       float score;
       struct stud *next;
     };
      /*  …………… comment  ……………    */
    int n;
    struct stud  create()
     {
	struct stud *head,*p1,*p2;
	n=0;
	p1=p2=(struct stud *)malloc(sizeof(struct stud));
	scanf("%ld,%s,%f",&p1->num,p1->name,&p1->score);
      /*   ……………comment  ……………      */
	head=NULL;
    while(p1!=0)
      {
	n=n+1;
	if(n==1) head=p1;
	else p2->next=p1;
	p1=(struct stud *)malloc(size(struct stud));
	scanf("%ld,%s,%f",&p1->num,p1->name,&p1->score);
       }
      p2->next=NULL;
      return(head);
    }

二、程序填空题(20分)。
    下面的程序是完成从键盘上输入若干行长度不一的字符串把其存到一个文件名为ttt.txt的磁盘文件上去,再从该文件中输出这些数据到屏幕上, 将其中的小写字母转换成大写字母。然而,该程序是一个不完整的程序,请在下划线空白处将其补充完整,以便得到正确答案,但不得增删原语句。
  #include <stdio.h>
     main( )
      {
	int i,flag;
	char str[80],c;
	FILE  *fp;
	if((fp=fopen("TTT","w"))==NULL)
	  {  printf("can't create file\n");
	     exit(0);
	  }
       for(flat=1;flag;)
	{ printf("请输入字符串\n");
	  gets(str);
	  fprintf(fp,"%s",str);
	  printf("是否继续输入?\n");
	  if((c=getchar()=='N'||  (1)  )
	    flag=0;
	  getchar();
	}
      fseek(fp,0,0);
      while(fscanf(fp,"%s",str)!=EOF)
	{ for(i=0;str[i]!='\0';i++)
	  if((str[i]>='a'&&(str[i]<='z'))
	    str[i]=_(2)  
	  printf("%s",str);
      }
      fclose(fp);
     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -