求更改下小弟我写的程序与一些有关问题
求更改下我写的程序与一些问题
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
#include <string.h>
#include <conio.h>
#include<stdio.h>
fstream iofile;
struct Node
{
string Name; //姓名
double BasicWage;//基本工资
double Reward; //奖金
double Forfeit; //罚款
Node *next;
};
class A
{
private:
Node *head;
public:
A(Node *h)
{
head=h;
}
~A()
{
}
Node * Create();
void Release();
Node *Insert();
void seek();
Node * Change();
void menu();
void count();
void File(fstream & ofile);
};
Node * A::Create()
{
head=(Node *)new Node;
if(!head)
{
cout<<"分配内存失败!"<<endl;
return NULL;
}
head->Name=" ";
head->BasicWage=0;
head->Reward=0;
head->Forfeit=0;
head->next=NULL;
return head;
}
//释放链表
void A::Release()
{
Node * ptr; //声明一个操作用的指针。
while(head!=NULL)
{
ptr=head;
head=head->next;
delete ptr; //释放节点资源。
}
}
void print(Node * ptr)
{
cout<<"姓名:"<<ptr->Name<<endl;
cout<<"基本工资:"<<ptr->BasicWage<<endl;
cout<<"奖金:"<<ptr->Reward<<endl;
cout<<"罚款:"<<ptr->Forfeit<<endl;
cout<<"总和:"<<ptr->BasicWage+ptr->Reward-ptr->Forfeit<<endl;
}
Node * A::Insert()
{
Node *pNew; //声明一个新节点
char again;
string Cname;
double CbasicWage,Creward,Cforfeit;
do
{
pNew=(Node *)new Node;
cout<<"请输入姓名:";
cin>>Cname;
cout<<endl<<"请输入基本工资:";
cin>>CbasicWage;
cout<<endl<<"请输入奖金:";
cin>>Creward;
cout<<endl<<"请输入罚款数:";
cin>>Cforfeit;
cout<<endl;
pNew->Name=Cname;
pNew->BasicWage=CbasicWage;
pNew->Reward=Creward;
pNew->Forfeit=Cforfeit;
pNew->next=head->next;
head->next=pNew;
cout<<"数据添加成功!是否继续添加?(Y/N)"<<endl;
cin>>again;
}while(again=='Y'||again=='y');
return head;
}
void A::File(fstream & ofile)
{
Node * pNode;
pNode=head->next;
ofile.clear(); //清除文件结束状态。
while(pNode)
{
ofile<<setw(10)<<left<<"姓名"<<setw(10)<<left<<"基本工资"<<setw(10)<<left<<"奖金"<<setw(10)<<left<<"罚单"<<setw(10)<<left<<"应付工资"<<endl;
ofile<<setw(10)<<left<<pNode->Name
<<setw(10)<<left<<pNode->BasicWage
<<setw(10)<<left<<pNode->Reward
<<setw(10)<<left<<pNode->Forfeit
<<setw(10)<<left<<pNode->BasicWage+pNode->Reward-pNode->Forfeit
<<endl;
pNode=pNode->next;
}
cout<<"数据文件保存成功!"<<endl;
}
void main()
{
Node *head=0;
A a(head);
head=a.Create();
iofile.open("E:工资.xls",ios_base::in|ios_base::out|ios_base::app);
if(!iofile)
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
#include <string.h>
#include <conio.h>
#include<stdio.h>
fstream iofile;
struct Node
{
string Name; //姓名
double BasicWage;//基本工资
double Reward; //奖金
double Forfeit; //罚款
Node *next;
};
class A
{
private:
Node *head;
public:
A(Node *h)
{
head=h;
}
~A()
{
}
Node * Create();
void Release();
Node *Insert();
void seek();
Node * Change();
void menu();
void count();
void File(fstream & ofile);
};
Node * A::Create()
{
head=(Node *)new Node;
if(!head)
{
cout<<"分配内存失败!"<<endl;
return NULL;
}
head->Name=" ";
head->BasicWage=0;
head->Reward=0;
head->Forfeit=0;
head->next=NULL;
return head;
}
//释放链表
void A::Release()
{
Node * ptr; //声明一个操作用的指针。
while(head!=NULL)
{
ptr=head;
head=head->next;
delete ptr; //释放节点资源。
}
}
void print(Node * ptr)
{
cout<<"姓名:"<<ptr->Name<<endl;
cout<<"基本工资:"<<ptr->BasicWage<<endl;
cout<<"奖金:"<<ptr->Reward<<endl;
cout<<"罚款:"<<ptr->Forfeit<<endl;
cout<<"总和:"<<ptr->BasicWage+ptr->Reward-ptr->Forfeit<<endl;
}
Node * A::Insert()
{
Node *pNew; //声明一个新节点
char again;
string Cname;
double CbasicWage,Creward,Cforfeit;
do
{
pNew=(Node *)new Node;
cout<<"请输入姓名:";
cin>>Cname;
cout<<endl<<"请输入基本工资:";
cin>>CbasicWage;
cout<<endl<<"请输入奖金:";
cin>>Creward;
cout<<endl<<"请输入罚款数:";
cin>>Cforfeit;
cout<<endl;
pNew->Name=Cname;
pNew->BasicWage=CbasicWage;
pNew->Reward=Creward;
pNew->Forfeit=Cforfeit;
pNew->next=head->next;
head->next=pNew;
cout<<"数据添加成功!是否继续添加?(Y/N)"<<endl;
cin>>again;
}while(again=='Y'||again=='y');
return head;
}
void A::File(fstream & ofile)
{
Node * pNode;
pNode=head->next;
ofile.clear(); //清除文件结束状态。
while(pNode)
{
ofile<<setw(10)<<left<<"姓名"<<setw(10)<<left<<"基本工资"<<setw(10)<<left<<"奖金"<<setw(10)<<left<<"罚单"<<setw(10)<<left<<"应付工资"<<endl;
ofile<<setw(10)<<left<<pNode->Name
<<setw(10)<<left<<pNode->BasicWage
<<setw(10)<<left<<pNode->Reward
<<setw(10)<<left<<pNode->Forfeit
<<setw(10)<<left<<pNode->BasicWage+pNode->Reward-pNode->Forfeit
<<endl;
pNode=pNode->next;
}
cout<<"数据文件保存成功!"<<endl;
}
void main()
{
Node *head=0;
A a(head);
head=a.Create();
iofile.open("E:工资.xls",ios_base::in|ios_base::out|ios_base::app);
if(!iofile)