Monday, February 16, 2009

Exer 5 CS 121

Photobucket

#include
#include
#include

void main(){
clrscr();
int num,a,b,x,y,select;
printf("Want to create a NICE PATTERN?\nThis program could fit of what you lookin' for..!!");
printf("\n\nEnter the number of rows you want to execute:");
scanf("%d",&num);
printf("\nSelect pattern you want to appear!");
printf("\n\t¯-¯-¯ [A] for Pattern 1");
printf("\n\t¯-¯-¯ [B] for Pattern 2");
printf("\n\t¯-¯-¯ [C] for Pattern 3");
printf("\n\t¯-¯-¯ [D] for Pattern 4");
printf("\nEnter the CAPITAL letter you choose a certain pattern:");
scanf("%s",&select);

switch(select)
{
case 'A':
for(a=0,y=12;a<=num;a++,y++) { for(b=1,x=37;b<=a;b++,x++) { gotoxy(x,y); printf("*"); } } break; case 'B': for(a=0,y=12;a<=num;a++,y++) { for(b=1,x=37;b<=a;b++,x--) { gotoxy(x,y); printf("*"); } } break; case 'C': for(a=num,y=13;a<=num;a--,y++) { for(b=a,x=38;b>=1;b--,x++)
{
gotoxy(x,y);
printf("*");
}
}
break;
case 'D':
for(a=num,y=13;a>=1;a--,y++)
{
for(b=a,x=38;b>=1;b--,x--)
{
gotoxy(x,y);
printf("*");
}
}
break;
default:
printf("Inputted unavailable");
}
printf("\n\n\t\tW-O-W!! What a nice pattern you've got!!\n\t\t\tThank you for your cooperation..^-^");
printf("\n\n\t\t\t\t¯-¯-¯ Programmed by: SHERLUCK L. MERCADO");
printf("\n\t\t\t\t\tCS121(5820) / 12:30-2:30 / H1I");
getch();
}

No comments:

Post a Comment