Advertisement
Holey_yan

20140409_KUAS_VisualC++_Classwork_0409_Question_5_Answer_1

Apr 12th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. /********************************************************/
  2. /** 20140409 Classwork_0409 Question 5 Answer Method 1 **/
  3. /** Maker  : Yan                                       **/
  4. /** E-Mail : ssas1115577@gmail.com                     **/
  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.     int check = 0;
  18.  
  19.     for(int i = 1; i <= input * 2 + 1; i++)
  20.     {
  21.         for(int j = 1; j <= input * 2 + 1; j++)
  22.         {
  23.             if(i == j)
  24.             {
  25.                 if(i == input + 1 && j == input + 1)
  26.                 {
  27.                     printf("*");
  28.                 }
  29.                 else
  30.                 {
  31.                     printf("\\");
  32.                 }
  33.             }
  34.             else if(i == input + 1 || j == input + 1)
  35.             {
  36.                 if(i == input + 1)
  37.                 {
  38.                     printf("-");
  39.                 }
  40.                 else
  41.                 {
  42.                     printf("|");
  43.                 }
  44.             }
  45.             else if((input * 2 + 2 - j) == i)
  46.             {
  47.                 printf("/");
  48.             }
  49.             else
  50.             {
  51.                 if((check % 2) == 1)
  52.                 {
  53.                     printf("$");
  54.                 }
  55.                 else if((check % 2) == 0)
  56.                 {
  57.                     printf("@");
  58.                 }
  59.             }
  60.             check++;
  61.         }
  62.         printf("\n");
  63.     }
  64.     system("pause");
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement