本人先正苦心研读C++,但从中挫折不少,希望各位高手能帮我,这段代码在编译的时候出现问题,希望各位高手指点,我以后也会经常在论坛上发些自己写的代码,望各位能帮帮我!
#include "stdafx.h"
#include<iostream>
using namespace std;
class money
{
int i;
float hots[10];
public:
void accept_details()
{
for(i=0;i<10;i++)
{
cout<<"输入职工工资: ";
cin>>hots[i];
if(hots[i]<=0)
{
cout<<"the amount should begreater than zero."<<endl;
i=i-1;
}
}
int i=0;
while(i<9);
{
if(hots[i]<hots[i+1])
{
float temp;
temp=hots[i];
hots[i]=hots[i+1];
hots[i+1]=temp;
i=0;
continue;
}
else i++;
}
cout<<"~~~~~~~~~~~~~~~~~~~~~~over all~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
}
void display_max()
{
cout<<"最高工资: "<<hots[0]<<endl;
}
void display_min()
{
cout<<"最低工资: "<<hots[9]<<endl;
}
void display_avg()
{
float avg,sum=0;
for (i=0;i<10;i++)
{
sum+=hots[i];
avg=sum/10;
cout<<"平均工资: "<<avg<<endl;
}
}
void count()
{
int m=0;
for(i=0;i<10;i++)
if (hots[i]>1000)
m++;
cout<<"工资超过1000: "<<m<<endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
money s1;
cout<<"请先输入工资: "<<endl;
s1.accept_details();
int b=1;
while(b)
{
cout<<"请您选择要查看的项目: "<<endl;
cout<<"1.最高工资: "<<endl;
cout<<"2.最低工资: "<<endl;
cout<<"3.高于1000的工资: "<<endl;
cout<<"4.平均工资: "<<endl;
cout<<"5.退出 "<<endl;
int a;
cin>>a;
if(a==1||a==2||a==3||a==4||a==5)
{
switch(a)
{
case 1:
s1.display_max();
break;
case 2:
s1.display_min();
break;
case 3:
s1.count();
break;
case 4:
s1.display_avg();
break;
case 5:
break;
}
}
cout<<"您是否还需要别的信息: "<<endl;
cout<<"是请按'1',否请按'2'。"<<endl;
cin>>b;
}
return 0;
}