| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 629 人关注过本帖
标题:谁帮我修改一下这段代码!winTC下编辑提示错误
只看楼主 加入收藏
haileishui
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-17
结帖率:0
收藏
已结贴  问题点数:10 回复次数:3 
谁帮我修改一下这段代码!winTC下编辑提示错误
在WIN tc下编译提示错误,不会修改!请高手帮忙/坐等~~~~
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <string.h>
struct student
{int num;/*学号*/
char name[20];/*名字*/
char sex[6];/*性别*/
int foxscore;/*fox成绩*/
int cscore;/*C语言    */
int englishscore;/*英语成绩*/
float zong;/*总成绩*/
int   mingci;/*名次 */
struct student *next;
};
int n=0;
struct student *begin()/*开辟一个存储空间*/
{
struct student *head;
head=(struct student *)malloc(sizeof(struct student));
if(head==NULL)
{
  printf("没有足够空间!\n");
}
head->next=NULL;
return(head);
}
struct student *input(struct student *head)/*输入函数 */
{int k=1;
struct student *student,*p1;
student=(struct student *)malloc(sizeof(struct student));
while(k)
{  printf("输入学生信息:\n");
     n++;
        printf("请输入学生学号:");
  scanf("%d",&student->num);
     printf("请输入学生姓名:");
  scanf("%s",&student->name);
     printf("请输入学生性别:");
  scanf("%s",&student->sex);
     printf("请输入学生fox成绩:\n");
        scanf("%d",&student->foxscore);
  printf("请输入学生c语言成绩:\n");
        scanf("%d",&student->cscore);
  printf("请输入学生英语成绩:\n");
        scanf("%d",&student->englishscore);
/*  printf("是否继续?是按1 否按0\n");
  scanf("%d",&k);

p1=(struct student *)malloc(sizeof(struct student));
    if(k!=0)
{
  student->next=p1;
     student=p1;
}
}
    student->next=NULL;
return(head);
}*/
if(n==1) {student->next=NULL; head=student;}
else {student->next=head;head=student;}
     printf("是否继续?是按1 否按0\n");
  scanf("%d",&k);

p1=(struct student *)malloc(sizeof(struct student));
    if(k!=0)
{
  p1->next=student;
     student=p1;
}
}
   
return(head);

}
struct student *revise(struct student *head)/* 修改函数 */
{ struct student *p1,*p2;int u,t;
  printf("请输入要修改学生学号:");
  scanf("%d",&u);  p1=head;
  while(p1->num!=u&&p1->next !=NULL )
  {p2=p1;p1=p1->next;}
  if(u==p1->num)
  {
    printf("学号:%d\n",p1->num);
    printf("姓名: "); puts(p1->name);/*printf("\n"); */
    printf("性别: "); puts(p1->sex);/*printf("\n");  */
    printf("fox成绩:%d\n",p1->foxscore);
    printf("c语言成绩:%d\n",p1->cscore);
    printf("英语成绩:%d\n",p1->englishscore);
  }
  printf("*******1.修改学号*****\n");
  printf("*******2.修改姓名*****\n");
  printf("*******3.修改性别*****\n");
  printf("*******4.修改成绩*****\n");
  printf(" please input choice(0-4):");
  scanf("%d",&t);
   switch(t)
   { case 1:    {printf("请输入学生学号:");
                 scanf("%d",&p1->num);} break;
     case 2: {printf("请输入学生姓名:");
              scanf("%s",&p1->name);} break;
     case 3:    {printf("请输入学生性别:");
         scanf("%s",&p1->sex);} break;
     case 4: { printf("请输入学生fox成绩:\n");
                  scanf("%d",&p1->foxscore);
            printf("请输入学生c语言成绩:\n");
                  scanf("%d",&p1->cscore);
            printf("请输入学生英语成绩:\n");} break;
   }
return(head);
}
void print(struct student *head)/* 输出函数 */
{struct student *p;
p=head;
do
{printf("学号:%d\n",p->num);
printf("姓名: "); puts(p->name);
printf("性别: "); puts(p->sex);
printf("fox成绩: %d\n",p->foxscore);
printf("c语言成绩: %d\n",p->cscore);
printf("英语成绩: %d\n",p->englishscore);
p->zong=(float)(p->foxscore+p->cscore+p->englishscore);
printf("总成绩: %.1f\n",p->zong);
printf("\n");
p=p->next; }while(p!=NULL);
}
void paiming(struct student *head)/* *****排名次***** */
{int i;     struct student  *p0,*p1,*p2;
for(i=1;i<n;i++)
{
  p2=head;p1=p2;
  p0=(struct student *)malloc(sizeof(struct student));
  while(p2->next!=NULL)
     {  p1=p2->next;
     if(p2->zong<p1->zong)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore; }
  /* ****************交换结点内容****************** */
     else
        {p2=p1;p1=p1->next;}
      }
   }
p1=head;
for(i=1;i<=n;i++)
{p1->mingci=i; p1=p1->next;
}
}
void chaxun(struct student *head)/* 查询函数*/
{
int t,nu,mc;char na[20];struct student *p1,*p2;
printf("*******1.按学号查询*****\n");
printf("*******2.按姓名查询*****\n");
printf("*******3.按名次查询*****\n");
printf("*******0.退出*********\n");
printf(" please input choice(0-3):");
scanf("%d",&t);
switch(t)
{
case 1: {printf("请输入学生学号:");
scanf("%d",&nu);
if(head==NULL) printf("无数据\n");
p1=head;
while(nu!=p1->num&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(nu==p1->num)
{printf("学号:%d\n",p1->num);
printf("姓名: "); puts(p1->name);
printf("性别: "); puts(p1->sex);
printf("fox成绩: %d\n",p1->foxscore);
printf("c语言成绩: %d\n",p1->cscore);
printf("英语成绩: %d\n",p1->englishscore);
printf("\n");
}
else printf("学号%d 的学生未找到\n",nu);};break;
case 2:    { printf("请输入学生姓名:");
scanf("%s",na);
     if(head==NULL) {printf("无数据\n");}
p1=head;
while(strcmp(na,p1->name)!=0&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(strcmp(na,p1->name)==0)
{printf("学号:%d\n",p1->num);
printf("姓名: "); puts(p1->name);
printf("性别: "); puts(p1->sex);
printf("fox成绩: %d\n",p1->foxscore);
printf("c语言成绩: %d\n",p1->cscore);
printf("英语成绩: %d\n",p1->englishscore);
}
else printf("该学生未找到\n");} break;
case 3:     {paiming(head);

printf("请输入学生名次:");
   scanf("%d",&mc);
   if(head==NULL) {printf("无数据\n");}
p1=head;
while(mc!=p1->mingci&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(mc==p1->mingci)
{printf("学号:%d\n",p1->num);
printf("姓名: "); puts(p1->name);
printf("性别: "); puts(p1->sex);
printf("fox成绩: %d\n",p1->foxscore);
printf("c语言成绩: %d\n",p1->cscore);
printf("英语成绩: %d\n",p1->englishscore);
}
else printf("名次%d 的学生未找到\n",mc);} break;
case 0:break;
}
}
struct student *shanchu(struct student *head)/* 删除函数 */
{
int t,nu,mc;char na[20];struct student *p1,*p2;
printf("*******1.按学号删除*****\n");
printf("*******2.按姓名删除*****\n");
printf("*******3.按名次删除*****\n");
printf("*******0.退出*********\n");
printf(" please input choice(0-3):");
scanf("%d",&t);
switch(t)
{
case 1:      {printf("请输入学学号:");
                 scanf("%d",&nu);
if(head==NULL) {printf("无数据\n");return NULL;}
p1=head;
while(nu!=p1->num&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(nu==p1->num)
{if(p1==head)head=p1->next;
else p2->next=p1->next;
n=n-1;
free(p1);printf("已删除");
}
else printf("学号%d 的学生未找到\n",nu);} break;
case 2:    { printf("请输入学生姓名:");
scanf("%s",na);
     if(head==NULL) {printf("无数据\n");return NULL;}
p1=head;
while(strcmp(na,p1->name)!=0&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(strcmp(na,p1->name)==0)
{if(p1==head)head=p1->next;
else p2->next=p1->next;
n=n-1;
free(p1);printf("已删除");
}
else printf("该学生未找到\n");} break;
case 3:   {  paiming(head);
printf("请输入学生名次:");
   scanf("%d",&mc);
   if(head==NULL) {printf("无数据\n");return NULL;}
p1=head;
while(mc!=p1->mingci&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(mc==p1->mingci)
{if(p1==head)head=p1->next;
else p2->next=p1->next;
n=n-1;
free(p1);printf("已删除");
}
else printf("名次%d的学生未找到\n",mc);} break;
case 0:break;
}
return(head);}
struct student *paixu(struct student *head)/* 排序函数 */
{int i,s,t;struct student *p1,*p2,*p0;   
printf("*******1.按学号排序*****\n");
printf("*******2.按姓名排序*****\n");
printf("*******3.按成绩排序*****\n");
printf("*******0.退出*********\n");
printf(" please input choice(1-3):");
scanf("%d",&t);
switch(t)
{
case 1:
{printf("********1.按学号升续*****\n");
  printf("*******2.按学号降续*****\n");
  scanf("%d",&s);
for(i=1;i<n;i++)
{
  p2=head;p1=p2;
  p0=(struct student *)malloc(sizeof(struct student));
  
  if(s==1)
  {while(p2->next!=NULL)
     {  p1=p2->next;
     if(p2->num>p1->num)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore; }
  /* ****************交换结点内容**************** */
     else
        {p2=p1;p1=p1->next;}
     }
   }
  else if(s==2)
{while(p2->next!=NULL)
     {  p1=p2->next;
     if(p2->num<p1->num)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore; }
  /* ****************交换结点内容****************** */
     else
        {p2=p1;p1=p1->next;}
     }
   }
}
}
break;
case 2:

{printf("*******1.按姓名升续*****\n");
  printf("*******2.按姓名降续*****\n");
scanf("%d",&s);
for(i=1;i<n;i++)
{
  p2=head;p1=p2;
  p0=(struct student *)malloc(sizeof(struct student));
  
  if(s==1)
  {while(p2->next!=NULL)
     {  p1=p2->next;
     if(strcmp(p1->name,p2->name)<0)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore; }
  /* ****************交换结点内容****************** */
     else
        {p2=p1;p1=p1->next;}
      }
   }
  else if(s==2)
  {while(p2->next!=NULL)
     {  p1=p2->next;
     if(strcmp(p1->name,p2->name)>0)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore;}
  /* ****************交换结点内容****************** */
     else
        {p2=p1;p1=p1->next;}
    }
   }
}
}
break;
case 3:
{ printf("*******1.按成绩升续*****\n");
  printf("*******2.按成绩降续*****\n");
  scanf("%d",&s);
for(i=1;i<n;i++)
{
  p2=head;p1=p2;
  p0=(struct student *)malloc(sizeof(struct student));

  if(s==1)
  {while(p2->next!=NULL)
     {  p1=p2->next;
     if(p2->zong>p1->zong)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore;}
  /* ****************交换结点内容****************** */
     else
        {p2=p1;p1=p1->next;}
      }
   }
  else if(s==2)
  {while(p2->next!=NULL)
     {  p1=p2->next;
     if(p2->zong<p1->zong)
       {p0->num=p2->num;strcpy(p0->name,p2->name);strcpy(p0->sex,p2->sex);
        p0->zong=p2->zong;p0->mingci=p2->mingci;
        p0->foxscore=p2->foxscore;p0->cscore=p2->cscore;p0->englishscore=p2->englishscore;
        p2->num=p1->num;strcpy(p2->name,p1->name);strcpy(p2->sex,p1->sex);
        p2->zong=p1->zong;p2->mingci=p1->mingci;
        p2->foxscore=p1->foxscore;p2->cscore=p1->cscore;p2->englishscore=p1->englishscore;
        p1->num=p0->num;strcpy(p1->name,p0->name);strcpy(p1->sex,p0->sex);
        p1->zong=p0->zong;p1->mingci=p0->mingci;
        p1->foxscore=p0->foxscore;p1->cscore=p0->cscore;p1->englishscore=p0->englishscore;}
  /* ****************交换结点内容****************** */
     else
        {p2=p1;p1=p1->next;}
  }
   }
}
}
break;
case 0:break;
    }
print(head);
return(head);}
/* *********操作文件******* */
void save(struct student *l)
{struct student *y;
FILE *fp;
char ch[20];
cout<<"请输入文件名!"<<endl;
scanf("%s",ch);
if((fp=fopen(ch,"wb+"))==NULL)
{cout<<"打开失败!"<<endl;
exit(0);}
for(y=l;y!=NULL;y=y->next)
fwrite(y,sizeof(struct student),1,fp);
fclose(fp);
cout<<"保存成功!"<<endl;
}
void readfl()
{struct student *k,st;
char ch[20];
FILE *fp;
k=&st;
cout<<"请输入您要打开的文件名!"<<endl;
scanf("%s",ch);
if((fp=fopen(ch,"rb+"))==NULL)
{cout<<"打开失败!"<<endl;
exit(0);}
fread(&st,sizeof(struct student),1,fp);
while(!feof(fp))
{printf("学号:%d\n",k->num);
  printf("姓名: "); puts(k->name);/* printf("\n");*/
  printf("性别: "); puts(k->sex);/* printf("\n"); */
  printf("fox成绩: %d\n",k->foxscore);
  printf("c语言成绩: %d\n",k->cscore);
  printf("英语成绩: %d\n",k->englishscore);
   
     k->zong=(float)(k->foxscore+k->cscore+k->englishscore);
      printf("总成绩: %.1f\n",k->zong);
fread(&st,sizeof(struct student),1,fp);
}
fclose(fp);
}
void main()
{int c; struct student *head;
head=begin();
  printf("\n\t\t***********学生成绩管理系统***********\n\n");
  while(1)
  {printf("\n\t\t****************菜单*****************\n\n");
   printf( "\t\t*\t1.建立信息          *\n");
   printf( "\t\t*\t2.信息修改          *\n");
   printf("\t\t*\t3.信息显示          *\n");
   printf("\t\t*\t4.信息查询          *\n");
   printf("\t\t*\t5.信息删除          *\n");              
   printf("\t\t*\t6.按学生信息排序    *\n");      
   printf("\t\t*\t7.信息保存          *\n");   
   printf("\t\t*\t8.信息输出          *\n");
   printf( "\t\t*\t0.退出              *\n");
   printf("\t\t*************************************\n");   
do {
  printf("\n\t\t please input choice(0-9):");
     scanf("%d",&c);
     }while(c<0||c>8);
/* return c;*/
switch (c)
  { case 1:head=input(head);break;
    case 2:if(n==0) printf("请先输入信息");
     else head=revise(head);break;
    case 3:if(n==0) printf("请先输入信息");
     else print(head); break;
    case 4:chaxun(head);break;
    case 5:head=shanchu(head);break;
    case 6:if(n==0) printf("请先输入信息");
     else head=paixu(head);break;
    case 7:save(head);break;
    case 8:if(n==0) printf("请先输入信息");
     else readfl();break;
    case 0:exit(0);break;}
}
}
搜索更多相关主题的帖子: 英语成绩 编辑 C语言 总成绩 空间 
2010-12-29 14:47
zhaoya881010
Rank: 9Rank: 9Rank: 9
来 自:芒砀古郡
等 级:蜘蛛侠
威 望:1
帖 子:339
专家分:1177
注 册:2010-11-21
收藏
得分:5 
win-tc里面没有那个c++的头文件 你怎么可能编译通过呢,用vc吧。

Go Go Go
2010-12-29 15:18
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:5 
scanf("%s",student->name);  //输入字符串不要加上&
     printf("请输入学生性别:");  
  scanf("%s",student->sex);   //
程序中还有另外一个地方也是一样的,楼主自己找吧
没有全部看完,也没有找到全部的错误。楼主的程序之长,纯属罕见


[ 本帖最后由 qq1023569223 于 2010-12-29 15:25 编辑 ]

   唯实惟新 至诚致志
2010-12-29 15:21
zhaoya881010
Rank: 9Rank: 9Rank: 9
来 自:芒砀古郡
等 级:蜘蛛侠
威 望:1
帖 子:339
专家分:1177
注 册:2010-11-21
收藏
得分:0 
看了下你这里面有没有用到类 只是输入输出的问题想在win-tc下运行你最好把头文件换成#include<stdio.h>,把程序里面的输入输出流改成标准的输入输出。

Go Go Go
2010-12-29 15:22
快速回复:谁帮我修改一下这段代码!winTC下编辑提示错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050372 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved