Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************/
- /** 20140409 Classwork_0409 Question 3 Answer **/
- /** Maker : Yan **/
- /** E-Mail : [email protected] **/
- /** Date : 2014/04/09 pm.10:45 **/
- /***********************************************/
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- printf("Enter a number: ");
- int input = 0;
- scanf("%d", &input);
- if(input <= 9)
- {
- for(int i = 1; i <= input; i++)
- {
- if(i != input)
- {
- for(int j = 1; j <= input - i; j++)
- {
- printf(" ");
- }
- if(i != 1)
- {
- printf("%d", i);
- printf(" ");
- }
- for(int j = 3; j <= i; j++)
- {
- printf(" ");
- }
- printf("%d\n", i);
- }
- else if(i == input)
- {
- for(int j = 1; j <= input; j++)
- {
- printf("%d ", i);
- }
- printf("\n");
- }
- }
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment