陆爱心吧 关注:1贴子:12
  • 0回复贴,共1
#include<iostream.h>
class GZ
{
double money;
public:
GZ(double m=1000);
static double SDS9;
static double SDS8;
static double SDS7;
static double SDS6;
static double SDS5;
static double SDS4;
static double SDS3;
static double SDS2;
static double SDS1;
void calSDS();
};
GZ::GZ(double m)
{
money = m;
}
void GZ::calSDS()
{
double SDS=0,x;
x=money-800;
if (x > 100000){
SDS = (x-100000)*SDS9;
x=100000;
}
if (x > 80000){
SDS += (x-80000)*SDS8;
x=80000;
}
if (x > 60000){
SDS += (x-60000)*SDS7;
x=60000;
}
if (x > 40000){
SDS += (x-40000)*SDS6;
x=40000;
}
if (x > 20000){
SDS += (x-20000)*SDS5;
x=20000;
}
if (x > 5000){
SDS += (x-5000)*SDS4;
x=5000;
}
if (x > 2000){
SDS += (x-2000)*SDS3;
x=2000;
}
if (x > 500){
SDS += (x-500)*SDS2;
x=500;
}
SDS += x*SDS1;
cout <<"此人的工资数为:"<<money<<endl;
cout <<"个人所得税为:"<<SDS<<endl;
money -= SDS;
cout <<"实际应发的工资为:"<<money<<endl;}
double GZ::SDS1 = 0.05;
double GZ::SDS2 = 0.10;
double GZ::SDS3 = 0.15;
double GZ::SDS4 = 0.20;
double GZ::SDS5 = 0.25;
double GZ::SDS6 = 0.30;
double GZ::SDS7 = 0.35;
double GZ::SDS8 = 0.40;
double GZ::SDS9 = 0.45;
void main()
{
GZ people1(1200), people2(5600), people3(480000);
people1.calSDS();
people2.calSDS();
people3.calSDS();
}
#include<iostream.h>
class FS
{
protected:
double xb;
double sb;
public:
FS operator * (FS &);
FS operator / (FS &);
FS operator - (FS &);
FS operator + (FS &);
void disp();
FS(double a=0, double b=0);
FS(FS &);
};
FS::FS(double a, double b)
{
sb = a;
xb = b;
}
FS::FS(FS &f)
{
sb = f.sb;
xb = f.xb;
}
void FS::disp()
{
cout<<"("<<sb;
if (xb >= 0)
cout<<"+";
cout<<xb<<"*i)";
}
FS FS::operator +(FS &f)
{
FS g = *this;
g.sb += f.sb;
g.xb += f.xb;
return g;
}
FS FS::operator -(FS &f)
{
FS g = *this;
g.sb -= f.sb;
g.xb -= f.xb;
return g;
}
FS FS::operator *(FS &f)
{
FS g = *this;
FS h;
h.sb = g.sb*f.sb - g.xb*f.xb;
h.xb = g.sb*f.xb + g.xb*f.sb;
return h;
}
FS FS::operator /(FS &f)
{
FS g = *this;
FS h(f.sb, -1*f.xb);
FS i = g * h;
double m = f.sb*f.sb + f.xb*f.xb;
g.xb = i.xb/m;
g.sb = i.sb/m;
return g;
}
void main()
{
FS a1(8,3), b1(7,-4);
FS a2(9,3), b2(4,2);
FS a3(4,6), b3(2,3);
FS a4(7,4), b4(2,1);
FS c1 = a1 + b1;
a1.disp();
cout<<" + ";
b1.disp();
cout<<" = ";
c1.disp();
cout<<endl;
FS c2 = a2 - b2;
a2.disp();
cout<<" - ";
b2.disp();
cout<<" = ";
c2.disp();
cout<<endl;
FS c3 = a3 *b3;
a3.disp();
cout<<" * ";
b3.disp();
cout<<" = ";
c3.disp();
cout<<endl;
FS c4 = a4 / b4;
a4.disp();
cout<<" / ";
b4.disp();
cout<<" = ";
c4.disp();
cout<<endl;
}


1楼2016-12-06 15:04回复