-
Notifications
You must be signed in to change notification settings - Fork 1
/
CombinationStringDigits.c
74 lines (46 loc) · 1.02 KB
/
CombinationStringDigits.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Finding all combinations of a given string digits- Given an input string of digits, find all combinations of numbers that can be formed using digits in the same order. Write a C program to find all the combinations of a user given string digits.
Test Case 1:
Input:
5
11 22 99 0 33 44
Output:
22 11 99 0 33
22 99 11 0 33
22 99 0 11 33
22 99 0 33 11
99 22 0 33 11
99 0 22 33 11
99 0 33 22 11
99 0 33 11 22
0 99 33 11 22
0 33 99 11 22
0 33 11 99 22
0 33 11 22 99
33 0 11 22 99
33 11 0 22 99
33 11 22 0 99
33 11 22 99 0
11 33 22 99 0
11 22 33 99 0
11 22 99 33 0
11 22 99 0 33
*/
#include<stdio.h>
int main()
{
int n; scanf("%d", &n);
int arr[n];
for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
for(int i = 0; i<n; i++){
int k = 0;
for(int j = 1; j<n; j++){
int temp = arr[k];
arr[k] = arr[j];
arr[j] = temp;
k++;
for(int m = 0; m < n; m++) printf("%d ", arr[m]);
printf("\n");
}
}
}