#include <iostream>;
#include <string>;
#include <vector>;using namespace std;struct student{
string name;
double Database;
double Philosophy;
double Software;
};int main()
{
vector<student> students;
student record;
string::size_type maxlen = 0; int i = 1;
for(i=1;i<5;i++)
{
cout<<"Please input NO."<<i<<"'s information:"<<endl;
cin>>record.name>>record.Database>>record.Philosophy>>record.Software;
maxlen = (maxlen>record.name.size())?maxlen:record.name.size();
students.push_back(record);
} for(vector<student>::size_type j = 0; j != students.size(); ++j)
{
cout<<students[j].name<<string(maxlen+1-students[j].name.size(), ' ');
cout<<'\t'; double score = (students[j].Database * 3 +students[j].Philosophy*2+students[j].Software*2)/(3+2+2);
cout<<score<<endl;
} return 0;
}
编译环境VC++ 6.0
出现如下警告:
g:\vc\score\score.cpp(1) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
g:\vc\score\score.cpp(2) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
g:\vc\score\score.cpp(3) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
#include <string>;
#include <vector>;using namespace std;struct student{
string name;
double Database;
double Philosophy;
double Software;
};int main()
{
vector<student> students;
student record;
string::size_type maxlen = 0; int i = 1;
for(i=1;i<5;i++)
{
cout<<"Please input NO."<<i<<"'s information:"<<endl;
cin>>record.name>>record.Database>>record.Philosophy>>record.Software;
maxlen = (maxlen>record.name.size())?maxlen:record.name.size();
students.push_back(record);
} for(vector<student>::size_type j = 0; j != students.size(); ++j)
{
cout<<students[j].name<<string(maxlen+1-students[j].name.size(), ' ');
cout<<'\t'; double score = (students[j].Database * 3 +students[j].Philosophy*2+students[j].Software*2)/(3+2+2);
cout<<score<<endl;
} return 0;
}
编译环境VC++ 6.0
出现如下警告:
g:\vc\score\score.cpp(1) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
g:\vc\score\score.cpp(2) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
g:\vc\score\score.cpp(3) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
解决方案 »
- 散分 散分 散分 为过节 散分 - 继续散分
- 无法创建列表的问题......
- 关于定制ListCtrl
- 进度条控件问题????
- 这样在VC中调用DX9向导
- 两个很很奇怪的小问题
- 求多进(线)程程序例子
- 为什么CDC的坐标系该如何设定,才能做到与设备无关?
- 想向另一个程序(比如当前活动窗口)的光标处输入字符,如何做到?
- 初学 GDI+,被 Image 类难住了
- 郁闷!我用到别人提供的DLL,结果调用时总出现:Windows 已在 EMUClient.exe 中触发一个断点。其原因可能是堆被损坏,这也说明 EMUClient.exe 中或它所加载的任何 DLL 中有 bug。
- syntax error : identifier 'PAPCFUNC'
#pragma warning( disable : 4786 )
#include <string>
#include <vector>
using namespace std; struct student{
string name;
double Database;
double Philosophy;
double Software;
}; int main()
{
vector <student> students;
student record;
string::size_type maxlen = 0; int i = 1;
for(i=1;i <5;i++)
{
cout <<"Please input NO." <<i <<"'s information:" <<endl;
cin>> record.name>> record.Database>> record.Philosophy>> record.Software;
maxlen = (maxlen> record.name.size())?maxlen:record.name.size();
students.push_back(record);
} for(vector <student> ::size_type j = 0; j != students.size(); ++j)
{
cout <<students[j].name <<string(maxlen+1-students[j].name.size(), ' ');
cout <<'\t'; double score = (students[j].Database * 3 +students[j].Philosophy*2+students[j].Software*2)/(3+2+2);
cout <<score <<endl;
} return 0;
}
compile后,再build就消失了,原因不详,但不再警告