solve this !!

Status
Not open for further replies.

QwertyManiac

Commander in Chief
Pretty simple construct really, is this a challenge or could you not do it?

Code:
#include<stdio.h>

int main()
{
    int i, j;
    for(i=4;i>0;i--)
    {
        for(j=2*i;j>0;j--)
        {
            printf("*");
            if(j==i+1)
            printf(" ");
        }
        
        printf("\n");
    }
}

Outputs as:
Code:
**** ****
*** ***
** **
* *
 
OP
F

frogonfloor

Broken In
thank you for helping me i am new in C
but my question was this
*******
*** ***
** **
* *
not this
**** ****
*** ***
** **
* *
 

QwertyManiac

Commander in Chief
Huh? Doesn't look like a definite pattern to me, why would you wanna build it? Are there any rules specified?

Anyway, here's my shot again:
Code:
#include<stdio.h>

int main()
{
    int i, j, a[4]={3, 3, 2, 1};
    
    for(i=0;i<4;i++)
    {
        for(j=(2*a[i]);j>0;j--)
        {
            printf("*");
            
            if((i==0)&&(j==a[i]+1))
            {
                printf("*");
                continue;
            }
            if(j==a[i]+1)
            {
                printf(" ");
                continue;
            }
        }
        
        printf("\n");
    }
}

Outputs as:
Code:
*******
*** ***
** **
* *
Its stupid to do this when there are no rules at all cause you can directly print the pattern! :p
 
Status
Not open for further replies.
Top Bottom