Holey_yan

20140409_KUAS_VisualC++_Classwork_0409_Question_5_Answer_2

Apr 12th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. /********************************************************/
  2. /** 20140409 Classwork_0409 Question 5 Answer Method 2 **/
  3. /** Maker  : Yan                                       **/
  4. /** E-Mail : [email protected]                     **/
  5. /** Date   : 2014/04/09 pm.11:16                       **/
  6. /********************************************************/
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. void main()
  12. {
  13.     printf("Enter a number: ");
  14.     int input = 0;
  15.     scanf("%d", &input);
  16.  
  17.     for(int i = 1; i <= input * 2 + 1; i++)
  18.     {
  19.         for(int j = 1; j <= input * 2 + 1; j++)
  20.         {
  21.             if(i == j)
  22.             {
  23.                 if(i == input + 1 && j == input + 1)
  24.                 {
  25.                     printf("*");
  26.                 }
  27.                 else
  28.                 {
  29.                     printf("\\");
  30.                 }
  31.             }
  32.             else if(i == input + 1 || j == input + 1)
  33.             {
  34.                 if(i == input + 1)
  35.                 {
  36.                     printf("-");
  37.                 }
  38.                 else
  39.                 {
  40.                     printf("|");
  41.                 }
  42.             }
  43.             else if((input * 2 + 2 - j) == i)
  44.             {
  45.                 printf("/");
  46.             }
  47.             else
  48.             {
  49.                 if((i % 2 == 1 && j % 2 == 0) || (i % 2 == 0 && j % 2 == 1))
  50.                 {
  51.                     printf("$");
  52.                 }
  53.                 else
  54.                 {
  55.                     printf("@");
  56.                 }
  57.             }
  58.         }
  59.         printf("\n");
  60.     }
  61.     system("pause");
  62. }
Advertisement
Add Comment
Please, Sign In to add comment