Pagini recente » Cod sursa (job #2837620) | Cod sursa (job #1543409) | Cod sursa (job #2387261) | Cod sursa (job #1174832) | Cod sursa (job #502209)
Cod sursa(job #502209)
#include <stdio.h>
int n,k,X[20],m;
int V[20];
int f(int a, int b) {
return a+b;
}
void func(int a, int b) {
int x;
printf("%d %d",a+b,x);
}
void af(int n) {
printf("%d",n); //332211000112233
if (n!=0) {
printf("%d",n);
af(n-1);
printf("%d",n);
} else
printf("%d",n);
printf("%d",n);
}
void af1(int i) {
if (i<=n) {
printf("%d",2*i);
af1(i+1);
printf("%d",2*i-1);
} else
printf("\n");
}
void p(int n) {
if (n) {
printf("%d",n); //32101012
p(n-1);
printf("%d",n);
p(n-1);
printf("%d",n);
} else
printf("%d",n);
}
int cont(int k) {
for (int i=1;i<k;i++)
if (X[i]==X[k])
return 0;
return 1;
}
void tipar(int k) {
for (int j=1;j<=k;j++) {
printf("%d",X[j]);
}
printf("\n");
}
/*
void back(int k) {
int i;
if (k>m) {
tipar(m);
} else {
for (i=1;i<=n;i++) {
X[k]= i;
if (cont(k))
back(k+1);
}
}
}
*/
void back(int k) {
int i;
if (k>m) {
tipar(m);
} else {
for (i=1/*X[k-1]+1*/;i<=n;i++) {
if (V[i]==0) {
X[k]= i;
V[i]=1;
back(k+1);
V[i]=0;
}
}
}
}
int main() {
n=8;
m=8;
// p(3);
back(1);
}