Linux目录结构与路径机制详解:绝对路径、相对路径及cd/pwd/ls实操
2026/10/11 2:07:40
作者 李祥
单位 湖北经济学院
请设计角度类 ANGLE,实现角度的输入、输出和加法运算。
#include <iostream> #include <iomanip> using namespace std; /* 你提交的代码将被嵌在这里 */ int main() { ANGLE a, b, c; a.Input(); b.Input(); c = a.Add(b); c.Output(); cout << endl; return 0; }16 28 57 32 49 1549 18 12要求:
ANGLE a; // 初始化为 0 度 0 分 0 秒ANGLE a(429, 18, 27); // 初始化为 429 度 18 分 27 秒ANGLE a; a.Input(); // 输入: 28 36 47 a.Output(); // 输出: 28 36 47ANGLE a(16, 28, 57), b(32, 49, 15), c; c = a.Add(b); // c 变为 49 度 18 分 12 秒参考示例:
class ANGLE{ private: int d,m,s; public: ANGLE(int dd=0,int mm=0,int ss=0):d(dd),m(mm),s(ss){} void Input(){ cin>>d>>m>>s; } void Output()const{ cout<<d<<" "<<m<<" "<<s; } ANGLE Add(const ANGLE &tt)const{ ANGLE t(d+tt.d,m+tt.m,s+tt.s); while(t.s>=60){ t.s-=60; t.m++; } while(t.m>=60){ t.m-=60; t.d+=1; } return t; } };