Our first item was a cross which size depends on user input...
The conditions are: input is odd number, ranging from 3-99, after a run, ask for input (1/0) in order to continue/end, respectively..
I used this code:
#include<stdio.h>
int b;
main()
{
int x, y, a;
clrscr();
b=1;
while(b !=0)
{
clrscr();
printf("Please enter a number:");
scanf("%d", &a);
if(a%2==1)
{
if(3<=a||a>100)
{
for(x=1;x<=a;x++)
{
for(y=1;y<=a;y++)
{
if(y==((a/2)+1))
{ printf("*"); }
else if(x==((a/2)+1))
{ printf("*"); }
else
{ printf(" "); }
}
printf("\n");
}
}
else
{ printf("INVALID!"); }
}
else
{ printf("INVALID!"); }
printf("[1] to continue [0] to end...");
scanf("%d", &b);
}
clrscr();
printf("Thanx!");
getch();
}
My problem is the second item, same conditions, but the figure is a ribbon... I can't figure out what to replace the IF/ELSE statements...
I tried changing the IF statement to
IF(y==1||y==a) { printf("*"); }
and the out put is a figure of "H"... am I close to getting the ribbon figure?
Please give me hints on what to do.... THANX!!!
example of the ribbon:
INPUT=5
*___*
**_**
*****
**_**
*___*
"_" is equivalent to space
INPUT=7
*_____*
**___**
***_***
*******
***_***
**___**
*_____*

New Topic/Question
Reply




MultiQuote




|