#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

解决方案 »

  1.   

    实在要去掉
     #pragma   warning(   disable   :   4786   )
      

  2.   

    哦,是 #pragma   warning(   disable   :   4067  )
      

  3.   

    #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; 

      

  4.   

    #include  <iostream> ;-----------------------有这样的写法??
      

  5.   

    这个你先
    compile后,再build就消失了,原因不详,但不再警告