首页 > 其他分享 >4.27打卡

4.27打卡

时间:2023-04-27 21:24:37浏览次数:34  
标签:real temp int CComplex imag 打卡 c1 4.27

 

#include<bits/stdc++.h>
using namespace std;
class Time
{
    private:
    int minute;
    int hour;
    public:
    void set(int h, int m)
    {
        minute = m;
        hour = h;
    }
    friend int operator-(Time, Time);
};

int operator-(Time t2, Time t1)
{
    return(t2.hour-t1.hour)*60+t2.minute-t1.minute;
}

int main()
{
    int a, b, c, d;
    Time t1, t2;
    cin >> a >> b >> c >> d;
    do{
        t1.set(a,b);
        t2.set(c,d);
        cout <<(t2-t1)<<endl;
        cin >> a>> b >> c >> d;
    }while(!(a == 0 && b == 0 && c == 0 && d == 0));
}

 

 

 

#include<bits/stdc++.h>
using namespace std;
class CComplex
{
    public:
    CComplex(double r=0, double i=0):real(r), imag(i){};
    CComplex operator+(const CComplex& c)
    {
        CComplex temp;
        temp=*this;
        temp.real += c.real;
        temp.imag += c.imag;
        return temp;
    };
    CComplex operator -=(const CComplex& c)
    {
        real-=c.real;
        imag-=c.imag;
        return *this;
    };
    friend CComplex operator-(const CComplex& c1, const CComplex& c2);
    void Display() const;
    private:
    double real;
    double imag;
};
    CComplex operator-(const CComplex& c1, const CComplex& c2)
    {
        CComplex temp;
        temp.real=c1.real-c2.real;
        temp.imag=c1.imag-c2.imag;
        return temp;
    }

void CComplex::Display() const
{
    cout <<"("<<real <<","<<" "<<imag<<")"<<endl;
}
int main()
{
    double r,m;
    cin>>r>>m;
    CComplex c1(r,m);
    cin >>r>>m;
    CComplex c2(r,m);
    CComplex c3=c1+c2;
    c3.Display();
    c3 = c1-c2;
    c3.Display();
    c3 -= c1;
    c3.Display();
    return 0;
}

 

标签:real,temp,int,CComplex,imag,打卡,c1,4.27
From: https://www.cnblogs.com/binglinll/p/17360234.html

相关文章

  • 打卡4
    问题描述:N个有序整数数列已放在一维数组中,利用二分查找法查找整数m在数组中的位置。若找到,则输出其下标值;反之,则输出“Notbefound!”。流程图: 伪代码:N<-10a[N]<-{10个有序整数}k<-1inputmwhlielow<=highmid=(low+high)/2ifm<a[mid]high<-mid-1elseifm>a[mid]......
  • 每日打卡java字符串
    importcom.ith.demo1.main;importcom.ith.demo1.phone;importjava.util.ArrayList;importjava.util.Scanner;importjava.util.StringJoiner;//PressShifttwicetoopentheSearchEverywheredialogandtype`showwhitespaces`,//thenpressEnter.Youcannows......
  • 2023.4.27
     1//实验六任务22#include<iostream>3#include<string>4usingnamespacestd;5classPeople6{7public:8People(){}9~People(){}10voidsetValue(intm,stringstr)11{12age=m;13name=str;......
  • c++打卡练习(18)
    猜牌术魔术师利用一副牌中的13张黑桃,预先将它们排好后迭在一起,并使牌面朝下。然后他对观众说:我不看牌,只要数数就可以猜到每张牌是什么,我大声数数,你们听,不信?你们就看,魔术师将最上面的那张牌数为1,把它翻过来正好是黑桃A,他将黑桃A放在桌子上,然后按顺序从上到下数手中的余牌,第二次......
  • 4月27日打卡
    美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧!输入格式:输入在一行中给出正方形边长N(3≤N≤21)和......
  • 2023.4.27编程一小时打卡
    一、问题描述:建立一个向量容器的实例s,不断对s调用push_back向其中增加新的元素,观察在此过程中s.capacity()的变化。二、解题思路:首先,编写一个向量容器vector<int>s,利用循环对其进行不断调用push_back,再输出它的capacity()函数观察它向量容器的容量的变化。三、代码实现:1#in......
  • 4.27
    #include<stdio.h>voidprint(ints[]);intjudge(intc[]);intj=0;main(){intsweet[10]={10,2,8,22,16,4,10,6,14,20};inti,t[10],l;printf("child12345678910\n");printf("......................\n");printf("tim......
  • 2023.4.27
    //Parent.vue<template>   <childv-model="value"></child></template><script>exportdefault{   data(){       return{           value:1       }   }}//Child.vue<template>   <input:value="value&......
  • 周四打卡
    题目描述:编写一个程序,实现将用户输入的字符串中的所有空格替换为下划线的功能。例如,输入字符串"Thequickbrownfoxjumpsoverthelazydog",输出结果为"The_quick_brown_fox_jumps_over_the_lazy_dog"。设计思路:接收用户输入的字符串。遍历字符串中的每个字符,如果是空格......
  • 打卡5
    #include<iostream>#include<fstream>#include<cstring>usingnamespacestd;//定义教师结构体structTeacher{intid;//工号stringname;//姓名chargender;//性别};intmain(){intN;cout<<&quo......