Advertisement
dmilicev

challenge1_v1.c

Jun 7th, 2020
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. /*
  2.  
  3.     challenge1_v1.c
  4.  
  5.     Challenge from Amit Singh Raghuvanshi
  6.     https://web.facebook.com/amitsingh.amitsingh.395
  7.  
  8.     https://web.facebook.com/photo/?fbid=2211324442346784&set=gm.1600975926727918
  9.  
  10.     Try in less lines of code. Here is his try:
  11.     https://pastebin.com/RBUpTgRH
  12.  
  13.     Below I changed his code which is now properly indent
  14.     but still doesn't look like the image.
  15.  
  16.  
  17.     You can find all my C programs at Dragan Milicev's pastebin:
  18.  
  19.     https://pastebin.com/u/dmilicev
  20.  
  21. */
  22.  
  23. #include <stdio.h>
  24.  
  25. int main()
  26. {
  27.     char a[]="*S*R*I* *R*A*M*";
  28.     int i,j;
  29.  
  30.  
  31.     for(i=0;i<2*15+1;i++)
  32.     {
  33.         for(j=0;j<2*15+1;j++)
  34.         {
  35.             if(i==0||i==2*15||j==0||j==2*15)
  36.                 printf("* ");
  37.             else if(i==1||j==1||i==2*15-1||j==2*15-1)
  38.             {
  39.                 if(j%2==1&&i%2!=0)
  40.                 {
  41.                     if(i==1)
  42.                         printf("%c ",a[j/2]);
  43.                     else if(j==1)
  44.                         printf("%c ",a[i/2]);
  45.                     else if(j==2*15-1)
  46.                         printf("%c ",a[15-i/2-1]);
  47.                     else
  48.                         printf("%c ",a[15-j/2-1]);
  49.                 }
  50.                 else
  51.                     printf("* ");
  52.             }
  53.             else if((i==2&&j>=2)||(i==2*15-2&&j<=2*15-2)||(j==2&&i>=2)||(j==2*15-2&&i<=2*15-2))
  54.                 printf("* ");
  55.             else if(i==j||i==(2*15-j))
  56.                 printf("* ");
  57.             else
  58.                 printf("  ");
  59.         }
  60.         printf("\n");
  61.     }
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement