#include <iostream>
using namespace std;
int main() {
int tmp = 1, total = 0;
for (int baris = 2; baris < 10; baris++) {
for (int angka = 1; angka <= baris; angka++) {
cout << angka;
if (angka % 2 != 0 && angka < baris) {
cout << " + ";
} else if (angka % 2 == 0 && angka < baris) {
cout << " * ";
} else {
if (angka % 2 != 0) tmp *= angka; else tmp += angka;
cout << " = " << tmp;
total += tmp;
}
}
cout << endl;
}
cout << "----------------------------------------" << endl;
cout << "Total = " << total;
cin.sync();
cin.get();
return 0;
}
Senin, 05 Juli 2010
Jawaban UTS Pemrograman Dasar I
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar