Showing posts with label pasir. Show all posts
Showing posts with label pasir. Show all posts

Tuesday, 16 April 2013

Jam Pasir Angka C++


#include<iostream.h>
main()
{
int a, b, c, d;
c=0;
for (a=4;a>=1;a--)
{
for (b=4;b>=a;b--)
{cout<<" ";}
for (b=a;b>=1;b--)
{c=c+1;
cout<<c<<" ";}
cout<<endl;}
c=10;
for (a=3;a>=1;a--)
{
for (b=1;b<=a;b++)
{cout<<" ";}
for (b=a;b<=4;b++)
{c=c-1;
cout<<c<<" ";}
cout<<endl;}}


Jam Pasir C++


#include<iostream.h>
main()
{
int a, b, c, d;
char x;

cout<<"input angka\t= ";
cin>>a;
cout<<"input karakter\t= ";
cin>>x;

for (b=1;b<=a;b++)
{
for (c=b;c>=1;c--)
{cout<<" ";}
for (d=a;d>=b;d--)
{cout<<x<<" ";}
cout<<endl;}

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

{
for (c=b;c<=a;c++)
{cout<<" ";}
for (d=1;d<=b;d++)
{cout<<x<<" ";}
cout<<endl;}}