这个程序怎么老是有错误,急!!

pwycctv 2004-03-21 09:54:21
程序如下:
#include <iostream>
#include <string>
using namespace std ;

void inputs() ;

void main ()
{

int studentNum = 10 ;
cout << "请输入学生人数 > " ;
cin >> studentNum ;
for ( int i = 0 ; i < studentNum ; i++ )
inputs() ;

}

void inputs(void )
{

string name ;
int classID = 1 ;
int Cgrade = 0 ;
int Egrade = 0 ;
int Mgrade = 0 ;
int Pgrade = 0 ;
int Chgrade = 0 ;
int Hgrade = 0 ;
int Ggrade = 0 ;
int Bgrade = 0 ;
int total = 0 ;
int average = 0 ;
cout << endl << "姓名 >" ;
cin >> name ;
cout << "组别 > " ;
cin >> classID ;
cout << "语文成绩 >" ;
cin >> Cgrade ;
cout << "英语成绩 >" ;
cin >> Egrade ;
cout << "数学成绩 >" ;
cin >> Mgrade ;

// 各别科目部分
if ( classID == 1 )
{
cout << "历史成绩 >" ;
cin >> Hgrade ;
cout << "地理成绩 >" ;
cin >> Ggrade ;
total = Cgrade + Egrade + Mgrade + Hgrade + Ggrade ;
average = total / 5 ;
}
else if ( ( classID == 2 ) || ( classID == 3 ) )
{
cout << "物理成绩 >" ;
cin >> Pgrade ;
cout << "化学成绩 >" ;
cin >> Chgrade ;
if ( classID == 3 )
{
cout << "生物成绩 >" ;
cin >> Bgrade ;
total = Cgrade + Egrade + Mgrade + Pgrade + Chgrade + Bgrade ;
average = total / 6 ;
}
else
{
total = Cgrade + Egrade + Mgrade + Pgrade + Chgrade ;
average = total / 5 ;
}
}

cout << endl << "*******************************" << endl ;
cout << "Student name is " << name <<endl ;
cout << "Total is " << total << endl ;
cout << "Average is " << average << endl ;
cout << endl << "*******************************" << endl ;

}



编辑后,出现如下错误,小弟初学c++,请高手请教
--------------------Configuration: df - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
df.cpp
e:\program files\mvs\myprojects\df\df.cpp(82) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

df.exe - 1 error(s), 0 warning(s)

...全文
15 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangfjj 2004-03-22
  • 打赏
  • 举报
回复
我用的跟你的一样呀
pwycctv 2004-03-22
  • 打赏
  • 举报
回复
还是不行,
我用的是:"创天中文VC++"
不知道和这个有关系没有?
c2y 2004-03-21
  • 打赏
  • 举报
回复
看看是不是这里有问题:
#include <iostream>
#include <string>

改为:
#include <iostream.h>
#include <string.h>
zhangfjj 2004-03-21
  • 打赏
  • 举报
回复
你用的是c++ build?
我没有用过
zhangfjj 2004-03-21
  • 打赏
  • 举报
回复
--------------------Configuration: ch2_2 - Win32 Debug--------------------
Compiling...
ch2_1.cpp

ch2_1.obj - 0 error(s), 0 warning(s)
----------
应该建 Win32 console application
我把你的程序在VC里编译,用的工程是Win32 console application,没问题
看来是你创建工程时选择错了。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧