Minggu, 29 Juni 2014

Contoh Program Piramida Angka C++



Source code:
#include

#include

int main()

{

    int a, b, c, tinggi;

    cout<<"==========================================================="<

    cout<<"\tNAMA"<<"\t\tNPM"<<"\t\t\tJurusan"<

    cout<<"1.\tHandy Setiawan"<<"\t06.2011.1.05890"<<"\t\tT.Informatika"<

    cout<<"==========================================================="<

    cout << "masukan baris tinggi pyramid: ";

    cin >> tinggi;

    cout << "\n";

    for(a=1; a<=tinggi; a++)

    {

         for(c=tinggi; c>=a; c--){

             cout << " ";

         }

         for(c=a; c<2 data-blogger-escaped-a="" data-blogger-escaped-c="" data-blogger-escaped-o:p="">

         {

              b = c%10;

              cout << b;

         }

         for(c=2*(a-1); c>=a; c--)

         {

              b = c%10;

              cout << b;

         }

         cout << "\n";

    }

    cout<<"==========================================================="<

getch();
}

Tidak ada komentar:

Posting Komentar