首页 > 其他分享 >2023.4.24

2023.4.24

时间:2023-04-24 22:57:44浏览次数:33  
标签:24 temp vector3D cin int num 2023.4 operator

 

 1 //实验五任务二
 2 #include <iostream>
 3 using namespace std;
 4 class vector3D
 5 {
 6 private:
 7     float x,y,z;
 8 public:
 9     vector3D()
10     {
11         x = 0;
12         y = 0;
13         z = 0;
14     }
15     friend ostream& operator <<(ostream &cout,vector3D &temp);
16     friend void setValue(vector3D &v);
17     vector3D operator+(vector3D &v)
18     {
19         vector3D temp;
20         temp.x = this->x + v.x;
21         temp.y = this->y + v.y;
22         temp.z = this->z + v.z;
23         return temp;
24     }
25     vector3D operator-(vector3D &v)
26     {
27         vector3D temp;
28         temp.x = this->x - v.x;
29         temp.y = this->y - v.y;
30         temp.z = this->z - v.z;
31         return temp;
32     }
33     vector3D& operator* (int a)
34     {
35         this->x =  a*this->x;
36         this->y =  a*this->y;
37         this->z =  a*this->z;
38         return *this;
39     }
40 };
41 ostream& operator <<(ostream &cout,vector3D &v)
42     {
43         cout<<"("<<v.x<<","<<v.y<<","<<v.z<<")";
44         return cout;
45     }
46 void setValue(vector3D &v)
47 {
48     cin>>v.x;cin>>v.y;cin>>v.z;
49 }
50 int main()
51 {
52     vector3D v1;
53     vector3D v2;
54     int num;
55     cin>>num;
56     if(num == 1)
57     {setValue(v1);}
58     else if(num == 2)
59     {
60         setValue(v1);
61         setValue(v2);
62     }
63     int a;
64     cin>>a;
65     vector3D v3;
66     v3 = v1 + v2;
67     cout<<v3<<endl;
68     v3 = v1 - v2;
69     cout<<v3<<endl;
70     v3 = v1*a;
71     cout<<v3<<endl;
72     return 0;
73 }

 

标签:24,temp,vector3D,cin,int,num,2023.4,operator
From: https://www.cnblogs.com/muzhaodi/p/17351245.html

相关文章

  • day55(2023.4.24)
    1.应用程序分层 应用程序分层实现在分层项目中实现查询业务UserDao接口 UserDaoImpl接口实现类 UserService接口 UserServiceImpl接口实现类 web 此时数据库中的数据 运行结果2.封装通用的BaseDao封装通用的DML操作BaseDao接口 BaseDaoImpl接......
  • 4.24
    1#include<iostream>2usingnamespacestd;3classDataType4{5public:6DataType(inti)7{8data.i=i;9type=INT;10}11DataType(charc)12{13data.c=c;14type=CHAR;1......
  • 4.24每日总结
       今天是第一阶段验收,王老师说这次的展示的功能比较单一,场景应用的构想也不够完善。今天看到一个组用python写的人脸识别,效果很好,与我们web端相比确实体现了差距。这几天会抓紧时间完善功能和场景应用的问题。......
  • 2023 4 24
    #include<iostream>usingnamespacestd;classclock{public:clock(inthour=0,intminture=0,intsecond=0);voidshowtime()const;clock&operator++();clockoperator++(int);private:inthour,minture,second;};clock::clock(......
  • 4.24打卡
    二、设计思路、1.先输出前两个月的兔子数,然后进入循环2.循环中每过一个月都会有新兔子产生,迭代求出当前月份的兔子数3.求和输出每个月的兔子总数 三、程序流程图 四、代码实现#include<stdio.h>usingnamespacestd;intmain(){longrab1=1,rab2=1,rab......
  • 4.24 贪心法学习笔记
    多写题解多交流才能学好oi。在这里贴了代码,为了看上去完整一些。 大概是一些自己学习的记录罢。贪心不算客观意义上的算法,感觉还不算一种策略机制。我认为更像一种思路,其内涵就是择优,解题时就去想怎样才能更优。根据最优的思路能去做很多,如果说贪心是一个题的正解的话太抽......
  • 2023.4.24——软件工程日报
    所花时间(包括上课):6.5h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习并开会。我了解到的知识点:1.了解了一些数据库的知识;2.了解了一些python的知识;3.了解了一些英语知识;5.了解了一些Javaweb的知识;4.了解了一些数学建模的知识;6.了解了一些计算机网络的知识;7.了解了一些考......
  • 23-4-24--子序列--最长连续递增子序列
    给定一个顺序存储的线性表,请设计一个算法查找该线性表中最长的连续递增子序列。例如,(1,9,2,5,7,3,4,6,8,0)中最长的递增子序列为(3,4,6,8)。输入格式:输入第1行给出正整数n(≤105);第2行给出n个整数,其间以空格分隔。输出格式:在一行中输出第一次出现的最长连续递增子序列,数字......
  • 4.24打卡
    一、问题描述: 魔术师利用一副牌中的 13 张黑桃,预先将它们排好后迭在一起,并使牌面朝下。然后他对观众说:我不看牌,只要数数就可 猜到每张牌是什么,我大声数数,你们听,不信?你们就看,魔术师将最上面的那张牌数为1,把它翻过来正好是黑桃A,他将黑桃A放在桌子上,然后按顺序从上到下数手中的......
  • 51 Nod 2497 数三角形 二分
    小b有一个仅包含非负整数的数组a,她想知道有多少个三元组(i,j,k),满足i<j<k且a[i],a[j],a[k]可能作为某个三角形的三条边的边长。 收起 输入第一行输入一个正整数n,表示数组a中元素个数;第二行n个非负整数,表示a中元素,以空格隔开;其中0<n≤1000,a中任意元素a[i]满......