4.19

1 #include<iostream>
2 using namespace std;
3 int main()
4 {
5     int x;
6     cin>>x;
7     cout<<"gong xi ni kao le 90 fen!";
8     return 0;
9 }

 

 1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int a,b,c,d;
 6     cin>>a;
 7     b=a/15;
 8     c=a/20;
 9     d=a*90;
10     cout<<b<<" "<<c<<" "<<d;
11     
12 }
13 #include<iostream>
14 using namespace std;
15 int main()
16 {
17     int N,M,S,X;
18     cin>>N>>M>>S;
19     X=N-M*S;
20     cout<<"hai sheng"<<" "<<X<<" "<<"mi! jia you ya!";
21     return 0;

 

  1 #include<iostream>
  2 #include<string>
  3 using namespace std;
  4 class People
  5 {
  6 private:
  7     int age;
  8     string name;
  9 public:
 10     People(){};
 11     People(int a,string b)
 12     {
 13         age=a;
 14         name=b;
 15     }
 16     ~People(){};
 17     void setValue(int m,string str)
 18     {
 19         age=m;
 20         name=str;
 21     }
 22     void display()
 23     {
 24         cout<<"age:"<<age<<endl<<"name:"<<name<<endl;
 25     }
 26 };
 27 class Student:public People
 28 {
 29 private:
 30     int ID;
 31 public:
 32     Student(){};
 33     Student(int a,string b,int c):People(a,b),ID(c){}
 34     ~Student(){}
 35     void setID(int m)
 36     {
 37         ID=m;
 38     }
 39     void displayID()
 40     {
 41         cout<<"ID:"<<ID<<endl;
 42     }
 43 };
 44 int main()
 45 {
 46     Student s(18,"jia",1111);
 47     s.display();
 48     s.displayID();
 49     int a,c;
 50     string b;
 51     cout<<"请依次输入 年龄 姓名 学号:";
 52     cin>>a>>b>>c;
 53     s.setValue(a,b);
 54     s.setID(c);
 55     s.display();
 56     s.displayID();
 57 }
 58 
 59 
 60 
 61 #include<iostream>
 62 #include<cmath>
 63 using namespace std;
 64 class SavingAccount
 65 {
 66 private:
 67     int id;
 68     double balance;
 69     double rate;
 70     int LastDate;
 71     double accumulation;
 72     void record(int date,double account);
 73     double accumulate(int date) const{
 74         return accumulation+balance*(date-LastDate);}
 75 public:
 76     SavingAccount(int date,int id,double rate);
 77     int Getid(){return id;}
 78     double getbalance(){return balance;}
 79     double Rate(){return rate;}
 80     void deposit(int date,double amount);
 81     void withdaw(int date,double amount);
 82     void settle(int date);
 83     void show();
 84 };
 85 SavingAccount::SavingAccount(int date,int id,double rate):id(id),balance(0),rate(0),LastDate(date),accumulation(0){
 86     cout<<date<<"\t#"<<id<<"is created"<<endl;
 87 }
 88 void SavingAccount::record(int date,double amount){
 89     accumulation=accumulate(date);
 90     amount=floor(amount*100+0.5)/100;
 91     balance+=amount;
 92     cout<<date<<"\t#"<<id<<"\t"<<amount<<"\t"<<balance<<endl;
 93 
 94 }
 95 void SavingAccount::deposit(int date,double amount){
 96     record(date,amount);
 97 }
 98 void SavingAccount::withdaw(int date,double amount){
 99     if(amount>getbalance())
100         cout<<"Error:not enough money"<<endl;
101     else
102         record(date,-amount);
103 }
104 void SavingAccount::settle(int date){
105     double interest=accumulate(date)*rate/365;
106     if(interest!=0)
107     record(date,interest);
108     accumulation=0;
109 }
110 void SavingAccount::show(){
111     cout<<"#"<<id<<"\tBalance:"<<balance;
112 }
113 int main()
114 {
115     SavingAccount sa0(1,21325302,0.015);
116     SavingAccount sa1(1,58320212,0.015);
117     sa0.deposit(5,5000);
118     sa1.deposit(25,10000);
119     sa0.deposit(45,5500);
120     sa1.deposit(60,4000);
121     sa0.settle(90);
122     sa1.settle(90);
123     sa0.show();cout<<endl;
124     sa1.show();cout<<endl;
125     return 0;
126 }

 

posted @ 2023-04-19 21:48  Code13  阅读(20)  评论(0编辑  收藏  举报