Program c++ Membuat Piramida Firaun dengan angka posisi terbalik
Contoh Output Piramida Firaun dengan angka posisi terbalik
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout << " PROGRAM PIRAMIDA SEGITIGA TERBALIK " << endl;
cout << " PROGRAM INI DIBUAT OLEH MOHAMMAD RIZKY AL KAHFI " << endl;
cout << "NIM : 021220015 " << endl;
cout << " " << endl;
cout << endl;
int baris, w, x, y, z;
cout << "Masukkan bilangan ganjil (positif) : ";
cin >> baris;
for( int w = 1; w <= baris; w++) {
for (int x = 1; x <= w; x++) {
cout << " ";
}
for (int y =(w*2-1); y <= baris; y++) {
cout <<setw(2)<< "";
z++;
cout << setw (2) << z << "";
}
cout << "\n";
}
return 0;
}
Komentar
Posting Komentar