形容条件艰苦的句子:编程达人帮我读读这程序

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 01:30:55
我现在是用turbo c 2.0做的c语言程序
但是我放到visual c++6.0中的c编译下编译没有办法通过
请帮忙修改一下、
不能单纯把后缀名改成.c++
必须是.c
谢谢
2.学生成绩管理程序设计
(1)选项菜单集成各功能函数模块
(2)录入学生成绩(姓名、学号、语文、数学成绩,总分自动计算)
(3)按总分排名次
(4)按姓名查找某学生成绩
(5)统计各课程的平均分、及格率、最高分、最低分
(6)打印成绩表

#include <iostream.h>
#include <stdlib.h>
struct student
{
int num;
char name[20];
int foxscore;
int cscore;
int englishscore;
struct student *next;
};

void menu()
{
cout<<" welecome to my student grade management system"<<endl;
cout<<" please follow everyone step in the menu"<<endl;
cout<<" 1.input information"<<endl;
cout<<" 2.total scores"<<endl;
cout<<" 3.sort"<<endl;
cout<<" 4.query"<<endl;
cout<<" ***************************************************"<<endl;
}
struct student *creat(struct student *head) /* 函数返回的是与节点相同类型的指针*/
{
struct student *p1,*p2;
p1=p2=(struct student*) malloc(sizeof(struct student)); /* 申请新节点*/
cin>>p1->num>>p1->name>>p1->foxscore>>p1->cscore>>p1->englishscore; /* 输入节点的值*/
p1-> next = NULL; /*将新节点的指针置为空*/
for(int i=1;i<=4;i++)
{
if (head==NULL) head=p1; /*空表,接入表头*/
else p2->next=p1; /*非空表,接到表尾*/
p2 = p1;
p1=(struct student *)malloc(sizeof(struct student)); /*申请下一个新节点*/
if(i<=3)
{
cin>>p1->num>>p1->name>>p1->foxscore>>p1->cscore>>p1->englishscore;
}
/*输入节点的值*/
}
return head; /*返回链表的头指针*/
}
我是菜鸟啊
能不能通过只修改代码来解决问题

进入命令行方式,再进VC的BIN目录\Program Files\Microsoft Visual Studio\VC98\Bin 运行VCVARS32.BAT设置环境变量
然后就可以再cl.exe /TP XXX.c
就行了
要是你一定要在VC环境下面编译就要在ALT+F7->C/C++->Project Options里手动加/TP

void count(struct student *head)
{
struct student *temp;
temp=head; /*取得链表的头指针*/
for(int i=1;i<=4;i++)
{
int m;
m=temp->foxscore+temp->cscore+temp->englishscore;
cout<<m<<endl;/*输出链表节点的值*/
temp=temp->next; /*跟踪链表增长*/
}
}
void sort(struct student *head)
{
struct student *tp;
tp=head;
int a[4];/*定义总分数组*/
int i,j,k;
a[1]=tp->foxscore+tp->cscore+tp->englishscore;
tp=tp->next;
a[2]=tp->foxscore+tp->cscore+tp->englishscore;
tp=tp->next;
a[3]=tp->foxscore+tp->cscore+tp->englishscore;
tp=tp->next;
a[4]=tp->foxscore+tp->cscore+tp->englishscore;
for(j=1;j<=3;j++)/*冒泡法排序*/
for(k=1;k<=4-j;k++)
if(a[k]<a[k+1])
{
int t=a[k];a[k]=a[k+1];a[k+1]=t;
}
for(i=1;i<5;i++)
cout<<a[i]<<endl;
}
void query(struct student *head)
{
struct student *temper;
temper=head;
int number;
cin>>number;
for(int i=1;i<=4;i++)
{
if(number==temper->num)
{
cout<<" name is:"<<temper->name<<endl;
cout<<" fox score is:"<<temper->foxscore<<endl;
cout<<" c score is:"<<temper->cscore<<endl;
cout<<" English score is:"<<temper->englishscore<<endl;
cout<<" congratulation,syetem have found what you want to search"<<endl;
}
temper=temper->next;
}
}
void main()
{
menu();
cout<<" firstly,please input information:"<<endl;
struct student *head;
head=NULL; /* 建一个空表*/
head=creat(head); /* 创建单链表*/
cout<<" secondly,count the total score each student:"<<endl;
count(head);
cout<<" thirdly,sorting the total score:"<<endl;
sort(head);
cout<<" enter num that you can search each shtudent's information"<<endl;
query(head);
cout<<" thanks you for use my student grade management system"<<endl;
}

你是NJUPT的吗?