Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int used[5],p[5];
- void permut(int pos) {
- if(pos>4) {
- for(int i=1; i<=4; i++) {
- printf("%d ",p[i]);
- }
- printf("\n");
- return;
- }
- for(int i=1; i<=4; i++) {
- if(used[i]==0) {
- p[pos]=i;
- used[i]=1;
- permut(pos+1);
- used[i]=0;
- }
- }
- }
- int main() {
- permut(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement