RieqyNS13 Moderator
Jumlah posting : 379 Join date : 2011-01-16 Age : 26 Lokasi : chmod 0655 GetConfig.SQL
| Subject: Buat Ombak Segitiga dengan While dan For Sat Feb 25, 2012 7:53 pm | |
| Langsung aja ya om,, program console ini untuk menampilkan output berupa segitiga ke arah vertikal dengan secara berulang-ulang sesuai dengan input yang dimasukkan.. ane pke printah While dan For..... sc : - Code:
-
//Author : RieqyNS13 // //E-mail : [You must be registered and logged in to see this link.]// //--NO COPAS--////////////////// #include <iostream> #include <windows.h> #include <iomanip> #include <string> using namespace std; int main() { system ("color A"); system ("TITLE Wong Edan"); int b; string v; cout<<"Masukkan Jumlah Perulangan = "; cin>>b; cout<<"Masukkan Nilai Setfill = "; cin>>v; while(b--) { for (int a=1; a<=b; a++) { cout<<setfill('*'); cout<<setw(a)<<v<<endl; Sleep (100); } int t=b; for (int c=1; c<=b; c++) { t = t-1; cout<<setfill('*'); cout<<setw(t)<<v<<endl; Sleep (100); } } system ("pause>nul"); return 0; } Ane compile di Dev-C++ gan,,, saumpama ane masukin Jumlah Perulangan 13, trus Nilai setfill nya ane masukin R kaya gini : - Code:
-
R *R **R ***R ****R *****R ******R *******R ********R *********R **********R ***********R **********R *********R ********R *******R ******R *****R ****R ***R **R *R R R R *R **R ***R ****R *****R ******R *******R ********R *********R **********R *********R ********R *******R ******R *****R ****R ***R **R *R R R R *R **R ***R ****R *****R ******R *******R ********R *********R ********R *******R ******R *****R ****R ***R **R *R R R R *R **R ***R ****R *****R ******R *******R ********R *******R ******R *****R ****R ***R **R *R R R R *R **R ***R ****R *****R ******R *******R ******R *****R ****R ***R **R *R R R R *R **R ***R ****R *****R ******R *****R ****R ***R **R *R R R R *R **R ***R ****R *****R ****R ***R **R *R R R R *R **R ***R ****R ***R **R *R R R R *R **R ***R **R *R R R R *R **R *R R R R *R R R R R SS: [You must be registered and logged in to see this image.]Walau ane masih smp kelas 2, tpi ane gak copas gan...:bangga:bangga [center] | |
|