Home > Blockchain >  Print stars to the screen up to the number entered
Print stars to the screen up to the number entered

Time:03-13

Type a program that writes the star as a table on the screen as much as the number entered from the keyboard.

I don't understand how to do it, can you help me?

(My problem is solved. Thanks to everyone who helped)

The example is:

Star St. Se: 54

Number of Columns : 12

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

CodePudding user response:

for (int i = 1; i <= numberOfStars; i  ){  
    System.out.print("*");
    if (i % columns == 0) System.out.println();  }

CodePudding user response:

include<stdio.h> #include<locale.h> int main() { setlocale(LC_ALL,"Turkish"); int sayi,icBosluk,disBosluk; int i; int j; char sembol; while(1){ printf("Bir sayi girin: "); scanf("%d",&sayi); printf("\nSembol Giriniz: "); scanf(" %c",&sembol); sayi = (sayi/2) 1; icBosluk=-1; disBosluk=sayi-1; for (i=1;i<=sayi;i ){ for(j=1;j<=disBosluk;j ) printf(" "); printf("%c",sembol); if(i!=1){ for(j=1;j<=icBosluk;j ) printf(" "); printf("%c",sembol); } printf("\n"); icBosluk =2; disBosluk--; } icBosluk-=4; disBosluk=1; for( i=1;i<sayi;i ){ for(j=1;j<=disBosluk;j ) printf(" "); printf("%c",sembol); if(i!=sayi-1) { for(j=1;j<=icBosluk;j ) printf(" "); printf("%c",sembol); } printf("\n"); icBosluk-=2; disBosluk ; } } return 0; }

  •  Tags:  
  • java
  • Related