Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /*
- Input:
- 4
- 1
- Output:
- 1 2 3 4 3 2 1
- 1 2 3 2 1
- 1 2 1
- 1
- */
- int main()
- {
- int i, n;
- scanf("%d", &n);
- while(n != 0){
- for(i = 1; i <= n; i++){
- if(i != n) {
- printf("%d ", 1);
- continue;
- }
- else {
- printf("%d ", n);
- }
- }
- for(i = n-1; i > 0; i--){
- if(i != n) {
- printf("%d ", 1);
- continue;
- }
- else {
- printf("%d ", n);
- }
- }
- n--;
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment