1. Kết quả Event Ghost 2016


    Dưới đây là danh sách những thành viên đoạt giải thưởng trong Event Ghost 2016

Giúp giùm mình code C++

Thảo luận trong 'Pascal, C , C++' bắt đầu bởi ngochivinh, 30 Tháng năm 2012.


  1. ngochivinh

    ngochivinh Member Chính Thức

    30
    32
    18
    Đang bí câu e và câu f:

    [​IMG]

    File:taikhoan.h
    Mã:
    #pragma once
    
    class taikhoan
    {
    protected:
    	long soTaikhoan;
    	char* hoTen;
    	double soDu;
    	char* date;
    public:
            void set_sd(double x);
    	double get_sd();
    	void set_stk(long t);
    	long get_stk();
    	taikhoan(void);
    	taikhoan(long,char*,double,char*);
    	taikhoan(const taikhoan &tk);
    	virtual void nhap()=0;
    	virtual void xuat()=0;
    	void napTien(double tien);
    	void rutTien(double tien);
    	~taikhoan(void);
    };
    
    
    File:taikhoan.cpp
    Mã:
    #include "StdAfx.h"
    #include "taikhoan.h"
    #include "string.h"
    #include "iostream"
    using namespace std;
    
    taikhoan::taikhoan(void)
    {
    }
    
    taikhoan::taikhoan(long soTaikhoan,char* hoTen,double soDu,char* date){
    	this->soTaikhoan=soTaikhoan;
    	this->hoTen=strdup(hoTen);
    	this->soDu=soDu;
    	this->date=strdup(date);
    }
    
    taikhoan::taikhoan(const taikhoan& tk){
    	this->soDu=tk.soDu;
    	this->soTaikhoan=tk.soTaikhoan;
    	this->hoTen=strdup(tk.hoTen);
    	this->date=strdup(tk.date);
    }
    
    void taikhoan::napTien(double tien){
    	cout<<"so tien nap vao:"<<tien<<"\n";
    	this->soDu+=tien;
    	cout<<"so du hien tai:"<<this->soDu<<"\n";
    }
    
    void taikhoan::rutTien(double tien){
    	cout<<"so tien rut ra:"<<tien<<"\n";
    	this->soDu-=tien;
    	cout<<"so du hien tai:"<<this->soDu<<"\n";
    }
    
    void taikhoan::set_sd(double x){
    	this->soDu=x;
    }
    
    double taikhoan::get_sd(){
    	return this->soDu;
    }
    
    void taikhoan::set_stk(long t){
    	this->soTaikhoan=t;
    }
    
    long taikhoan::get_stk(){
    	return this->soTaikhoan;
    }
    
    taikhoan::~taikhoan(void)
    {
    }
    
    File:taikhoantietkiem.h
    Mã:
    #pragma once
    #include "taikhoan.h"
    #include "string.h"
    class taikhoantietkiem:public taikhoan
    {
    private:
    	double laiSuat;
    	char* hinhThuc;
    	int soKy;
    public:
    	taikhoantietkiem(void);
    	taikhoantietkiem(long soTaikhoan,char* hoTen,double soDu,char* date,double laiSuat,char* hinhThuc,int soKy):taikhoan(soTaikhoan,hoTen,soDu,date){
    		this->laiSuat=laiSuat;
    		this->soKy=soKy;
    		this->hinhThuc=strdup(hinhThuc);};
    	void nhap();
    	void xuat();
    	double tinhLai();
    	~taikhoantietkiem(void);
    };
    
    
    File:taikhoantietkiem.cpp
    Mã:
    #include "StdAfx.h"
    #include "taikhoantietkiem.h"
    #include "math.h"
    #include "iostream"
    using namespace std;
    
    
    taikhoantietkiem::taikhoantietkiem(void)
    {
    }
    
    
    taikhoantietkiem::~taikhoantietkiem(void)
    {
    }
    
    void taikhoantietkiem::nhap(){
    	cout<<"nhap vao so tai khoan thanh toan"<<"\n";
    	cin>>this->soTaikhoan;
    	fflush(stdin);
    	this->hoTen=new char[30];
    	cout<<"nhap vao ho ten chu tai khoan thanh toan"<<"\n";
    	cin.getline(this->hoTen,29);
    	fflush(stdin);
    	cout<<"Nhap vao so du:"<<"\n";
    	cin>>this->soDu;
    	fflush(stdin);
    	cout<<"nhap vao ngay lap tai khoan:"<<"\n";
    	this->date=new char[30];
    	cin.getline(this->date,29);
    	fflush(stdin);
    	cout<<"Nhap vao lai Suat hang nam:"<<"\n";
    	cin>>this->laiSuat;
    	fflush(stdin);
    	cout<<"nhap vao hinh thuc tiet kiem:"<<"\n";
    	this->hinhThuc=new char[30];
    	cin.getline(this->hinhThuc,29);
    	fflush(stdin);
    	cout<<"nhap vao so ky:"<<"\n";
    	cin>>this->soKy;
    	fflush(stdin);
    }
    
    void taikhoantietkiem::xuat(){
    	cout<<"so tai khoan thanh toan:"<<this->soTaikhoan<<"\n";
    	cout<<" ho ten chu tai khoan thanh toan:"<<this->hoTen<<"\n";
    	cout<<"so du:"<<this->soDu<<"\n";
    	cout<<"ngay lap tai khoan:"<<this->date<<"\n";
    	cout<<" lai suat hang nam:"<<this->laiSuat<<"\n";
    	cout<<"hinh thuc tiet kiem"<<this->hinhThuc<<"\n";
    	cout<<"So ky la:"<<this->soKy<<"\n";
    	cout<<"so tien lai la:"<<this->tinhLai()<<"\n";
    }
    
    double taikhoantietkiem::tinhLai(){
    	
    	return pow(this->soDu*(this->laiSuat+1),this->soKy);
    }
    
    File:taikhoanthanhtoan.h
    Mã:
    #pragma once
    #include"taikhoan.h"
    class taikhoanthanhtoan:public taikhoan 
    {
    private:
    	double phiHangthang;
    public:
    	void nhap();
    	void xuat();
    	taikhoanthanhtoan(void);
    	taikhoanthanhtoan(long soTaikhoan,char* hoTen,double soDu,char* date,double phiHangthang):taikhoan(soTaikhoan,hoTen,soDu,date)
    	{this->phiHangthang=phiHangthang;};
    	~taikhoanthanhtoan(void);
    };
    
    
    File:taikhoanthanhtoan.cpp
    Mã:
    #include "StdAfx.h"
    #include "taikhoanthanhtoan.h"
    #include "iostream"
    using namespace std;
    
    taikhoanthanhtoan::taikhoanthanhtoan(void)
    {
    }
    
    void taikhoanthanhtoan::nhap(){
    	cout<<"nhap vao so tai khoan thanh toan"<<"\n";
    	cin>>this->soTaikhoan;
    	fflush(stdin);
    	this->hoTen=new char[30];
    	cout<<"nhap vao ho ten chu tai khoan thanh toan"<<"\n";
    	cin.getline(this->hoTen,29);
    	fflush(stdin);
    	cout<<"Nhap vao so du:"<<"\n";
    	cin>>this->soDu;
    	fflush(stdin);
    	cout<<"nhap vao ngay lap tai khoan:"<<"\n";
    	this->date=new char[30];
    	cin.getline(this->date,29);
    	fflush(stdin);
    	cout<<"Nhap vao phi hang thang:"<<"\n";
    	cin>>this->phiHangthang;
    	fflush(stdin);
    }
    
    void taikhoanthanhtoan::xuat(){
    	cout<<"so tai khoan thanh toan:"<<this->soTaikhoan<<"\n";
    	cout<<" ho ten chu tai khoan thanh toan:"<<this->hoTen<<"\n";
    	cout<<"so du:"<<this->soDu<<"\n";
    	cout<<"ngay lap tai khoan:"<<this->date<<"\n";
    	cout<<"phi hang thang:"<<this->phiHangthang<<"\n";
    }
    
    taikhoanthanhtoan::~taikhoanthanhtoan(void)
    {
    }
    
    File:danhsachtaikhoan.h
    Mã:
    #pragma once
    #include "taikhoan.h"
    #include "taikhoanthanhtoan.h"
    #include "taikhoantietkiem.h"
    
    class danhsachtaikhoan
    {
    private:
    	char* name;
    	taikhoan *ds[100];
    	int n;
    public:
    	danhsachtaikhoan(void);
    	danhsachtaikhoan(char* name,taikhoan* ds,int n);
    	double tongSodu();
    	double timKiem(long t);
    	void nhap();
    	void xuat();
    	~danhsachtaikhoan(void);
    };
    
    
    File:danhsachtaikhoan.cpp
    Mã:
    #include "StdAfx.h"
    #include "danhsachtaikhoan.h"
    #include "string.h"
    
    
    danhsachtaikhoan::danhsachtaikhoan(void)
    {
    }
    
    danhsachtaikhoan::danhsachtaikhoan(char* name,taikhoan* ds,int n){
    	this->name= strdup(name);
    	this->n=n;
    
    }
    
    double danhsachtaikhoan::tongSodu(){
    	double ts=0;
    	for(int i=0;i<this->n;i++)
    		ts=ts+ this->ds[i]->get_sd();
    	return ts;
    }
    
    double danhsachtaikhoan::timKiem(long t){
    	for(int i=0;i<this->n;i++)
    		if(this->ds[i]->get_stk() ==t)
    			return this->ds[i]->get_sd();
    }
    
    void danhsachtaikhoan::nhap(){
    	for(int i=0;i<this->n;i++)
    		this->ds[i]->nhap();
    }
    
    void danhsachtaikhoan::xuat(){
    	for(int i=0;i< this->n;i++)
    		this->ds[i]->xuat();
    }
    
    danhsachtaikhoan::~danhsachtaikhoan(void)
    {
    }
    
    Giúp mình câu e và câu f.
     

Chia sẻ trang này