PTA第三次上機

2022-02-06 20:08:16 字數 2334 閱讀 5646

#include #include #include using namespace std;

class polygon

; int perimeter();//計算多邊形邊長

void display();//輸出多邊形邊數和周長

int* reachsidelen();

};int polygon::perimeter()

return tot;

}void polygon::display()

int* polygon::reachsidelen()

class rectangle : protected polygon

; int perimeter();//計算矩形邊長

void display();//輸出多邊形邊數和周長

};int rectangle::perimeter()

void rectangle::display()

class equal_polygon : protected polygon

; int perimeter();//計算等邊多邊形邊長

void display();//輸出多邊形邊數和周長

};int equal_polygon::perimeter()

void equal_polygon::display()

int main()

tot --;

polygon p(tot);

int *p = p.reachsidelen();

for (i = 1; i <= tot; i++)

p.display();

} else if(ope == 1)

else if(ope == 2)

}return 0;

}

#include #include #include using namespace std;

class point_1d

; float distance( );//計算當前點到原點的距離

};float point_1d::distance()

class point_2d : protected point_1d

; float distance( );

};float point_2d::distance()

class point_3d : protected point_2d

; float distance( );

};float point_3d::distance()

int main()

else if(ope == 2)

else if(ope == 3)

}return 0;

}

用了sstream,主函式太長了。。

#include #include #include using namespace std;

class date;};

class time;};

class schedule : protected date, protected time;

bool operator < (const schedule & s2);

void display();

};void schedule::display() //the urgent schedule is no.1: 2014/6/27 8:0:1

bool schedule::operator < (const schedule & s2)

}int main()

else

}else

s1 += date[i];

} stream << s1;

stream >> d;

stream.clear();

bool flag2 = false;

for(i = 0; i < time.length(); i++)

else

}else

s2 += time[i];

} stream << s2;

stream >> s;

stream.clear();

schedule sch1(y, m, d, h, min, s, id);

if(sch1 < sch)sch = sch1; }

cout << "the urgent schedule is no.";

sch.display();

return 0;

}

C 第三次上機

題目一 假設有乙個字串strfilename d c 程式設計 實驗3 myfile.txt 使用字串方法,取出路徑中的檔名 myfile.txt 要求至少想出三種方法實現 1 using system using system.collections.generic using system.li...

第三次上機作業

1.列印所有的水仙花數,水仙花數是指各位數的立方和等於 該數本身 知識點 迴圈語句和條件語句 2.在控制台輸出圖形 3.輸入年月日,判斷這是這一年中的第幾天 知識點 迴圈語句 條件語句 4.輸入乙個4位整數,求將該數反轉以後的數,如原數1234,反轉後為4321.知識點 迴圈語句 條件語句 scan...

第三次上機實驗

2.圖形 include include graph.h using namespace std intmain ifndef graph h define graph h 類graph的宣告 class graph endif 類graph的實現 include graph.h include u...