Holey_yan

20140409_KUAS_VisualC++_Classwork_0409_Question_4_Answer

Apr 12th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. /***********************************************/
  2. /** 20140409 Classwork_0409 Question 4 Answer **/
  3. /** Maker  : Yan                              **/
  4. /** E-Mail : [email protected]            **/
  5. /** Date   : 2014/04/09 pm.11:00              **/
  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.             for(int k = 1; k <= input + 1; k++)
  22.             {
  23.                 if(i == k || j == k || i == input * 2 - (k - 2) || j == input * 2 - (k - 2))
  24.                 {
  25.                     printf("%3d", input - (k - 2));
  26.                     break;
  27.                 }
  28.             }
  29.         }
  30.         printf("\n");
  31.     }
  32.  
  33.     system("pause");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment