c++簡單程式設計-1

來源:互聯網
上載者:User

標籤:設計   程式設計   c語言   iostream   class   rest   switch語句   src   switch   

(一)

#include<iostream>
using namespace std;
int main() {
int day;
cin >> day;
switch (day) {
case 1:
case 2:
case 3:
case 4:
case 5:
cout << "Workday.Let‘s work hard." << endl;
break;
case 6:
case 7:
cout << "Weekend.Let‘s have a rest." << endl;
break;
default:
cout << "Day out of normal day" << endl;
break;
}
return 0;
}

(二)

# include<iostream>
using namespace std;
int main() {
int n, a, b = 0;
cout << "Enter the number:";
cin >> n;
cout << "The number in reverse order is:";
do {
a = n % 10;
b = b * 10 + a;
n /= 10;
} while (n != 0);
cout << b << endl;
return 0;
}

(實驗總結與體驗)

通過這次實驗,我瞭解到了C語言和C++的相似與不同之處,理解了例題中switch語句和break語句,算數運算式和迴圈語句的用法。程式編程並不是一次性就能完成的,往往需要多次的調試,這次實驗我也是在原有思想的基礎上不斷完善、調試才成功的,心中還有些小小的成就感。不過這次實驗相對比較簡單,有書上的例題作為基礎,期待下次的實驗。

c++簡單程式設計-1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.