首页 > 其他 > 详细

实验 4

时间:2018-04-23 23:59:18      阅读:244      评论:0      收藏:0      [点我收藏+]

第二题技术分享图片

using namespace std;
class Graph {
    public:
        Graph(char t, int n);   
        void draw();     
    private:
        char ch;
        int number;
};
Graph::Graph(char t, int n): ch(t), number(n) {}
void Graph::draw() 
{
    int i,j;
    for(i=0;i<=number;i++)
    {
    for(j=0;j<=number-i;j++)
    cout<<" ";  
    for(int j=0;j<2*i-1;j++)
            cout<<number;
        cout<<endl;
}
}
int main() {
    Graph graph1(‘*‘,5), graph2(‘$‘,7) ; 
    graph1.draw();
    graph2.draw(); 
    
    return 0; 
} ```
第三题

include

using namespace std;
class Fraction
{
public:
Fraction():top(0),bottom(1) {};
Fraction(int a,int b):top(a),bottom(b) {};
Fraction(int c):top(c),bottom(1){};
void add(Fraction p);
void sub(Fraction p);
void mul(Fraction p);
void div(Fraction p);
void display()
{
cout<<top<<"/"<<bottom<<endl;
};
void op();
private:
int top;
int bottom;
};
void Fraction:: add(Fraction p)
{

实验 4

原文:https://www.cnblogs.com/-Alone/p/8922618.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!