Jump to content

Recommended Posts

  • Moderators
Posted

Se citeste de la tastatura un numar natural n. De exemplu, pentru numarul 9 se va afisa 

*
**
***
****
*****
******
*******
********
*********
 

Rezolvare:

 

#include <stdio.h>
int main()
{
    unsigned n,i,j;
    scanf("%d", &n);
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=i;j++)
            printf("*");
        printf("n");
    }
}
 

 

 

 

 

Pentru piramida gen 

 

*********
********
*******
******
*****
****
***
**
*
 

se poate folosi codul

 

#include <stdio.h>
int main()
{
    unsigned n,i,j;
    scanf("%d", &n);
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n-i+1;j++)
            printf("*");
        printf("n");
    }
}
  • Upvote 2

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.