This program must calculate permutations but it gives me a result with smiley ,
Can someone help me, Thanks!!
#include <conio.h>
#include <stdio.h>
#include <math.h>
const n = 10,num=4;
int i,a[n];
void tipareste(){
int i;
for(i=0;i<num;i++)
{
printf(" %d \n", a[i]);
}
}
void permuta(int k)
{
int i,x;
if(k==1) tipareste() ;
else{
for(i=0;i<k;i++){
x=a[i];
a[i]=a[k];
a[k]=x;
permuta(k-1);
x=a[i];
a[i]=a[k];
a[k]=x;
}
}
}
int main()
{
for(i=0;i<n;i++){
a[i]=i;
}
printf("\n");
permuta(n);
return 0;
}
This program