diff --git a/755433/expense-app.cpp b/755433/expense-app.cpp new file mode 100644 index 0000000..a4d615b --- /dev/null +++ b/755433/expense-app.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +int main() { + //設定變數和多少筆資料 + int count_data, count_sum, total = 0; + cin >> count_data; + + //算出總金額 + for (int i = 0; i < count_data; i++) { + cin >> count_sum; + total = count_sum + total; + } + + //輸出總金額 + cout << "總共 " << total << " 元"; +} diff --git a/755433/mario.cpp b/755433/mario.cpp new file mode 100644 index 0000000..1c88f7b --- /dev/null +++ b/755433/mario.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; + +int main() { + //設定變數和輸入 + int num; + cout << "高度: "; + cin >> num; + + //設定幾行,輸出後換行 + for (int i = num; i > 0; i--) { + + //空格數目及輸出 + for (int j = 0; j < i - 1; j++) { + cout << " "; + } + + //井字號數目及輸出 + for (int k = 0; k < num - i + 1; k++) { + cout << "#"; + } + + cout << "\n"; + } +}