Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/combination_of_number.html on line 13

Warning: include(topsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/combination_of_number.html on line 13

Warning: include(): Failed opening 'topsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/combination_of_number.html on line 13

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 


Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/combination_of_number.html on line 31

Warning: include(adsc.html): failed to open stream: No such file or directory in /home/eng123/public_html/sourcecode/c/unix/combination_of_number.html on line 31

Warning: include(): Failed opening 'adsc.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/eng123/public_html/sourcecode/c/unix/combination_of_number.html on line 31

 
Combination of Numbers

--------------------------------------------------------------------------------

Description : This program will print all the combination of numbers as you enter. Just try it and let me know if there is any updation

Code :
/* Combination of Numbers */
#include <stdio.h>
#include <conio.h>
int a[20],b[20];
long int count=0;
long int cal=0;
long int ite=1;
long int tot[30];

main()
{
int i,val,k,n,tmp,j,sum=0;
clrscr();

printf("Enter the Number: ");
scanf("%d",&n);

ite=1;
for(i=1;i<n;i++)
ite = ite * i;

cal=ite/2;

if(n <=4 ) sum = 3;
else
for(i=5;i<=n;i++)
sum = sum + 3;

cal=cal/sum;
for(i=1;i<=n;i++)
{
/*scanf("%d",&a[i]);*/
a[i] = i; tot[i] = 0;
}
if(n==4) cal=1;
if(n==3)
prin(n,a[1],a[2],a[3]);
else if(n==1)
printf(" %d ",n);
else if(n==2)
{
printf("
%d %d<BR>,a[1],a[2]);
printf("%d %d ",a[2],a[1]);
}
else
for(val=1;val<=n;val++)
{
for(j=1;j<=n;j++)
{
b[j] = a[j];
}
for(i=1;i<=cal;i++)
{
if((n-3) == 1)
{
prin(n,b[n-2],b[n-1],b[n]);
tmp=b[1];
for(k=1;k<n;k++)
b[k] = b[k+1];
b[k]=tmp;
}
else
for(j=n-3;j>1;j--)
{
prin(n,b[n-2],b[n-1],b[n]);
tmp = b[n-3];
for(k=n-3;k<n;k++)
b[k] = b[k+1];
b[k] = tmp;
}
}
tmp = a[1];
for(i=1;i<n;i++)
a[i] = a[i+1];
a[i] = tmp;
}
printf("
cal = %ld<BR>,cal);
getch();
}
prin(int n,int a1,int a2,int a3)
{
int s,i,j,t;
int c[20],d[20];

for(s=1;s<=n-3;s++)
c[s]=a[s];

d[1]=a1;
d[2]=a2;
d[3]=a3;

for(i=1;i<=3;i++)
{
for(j=1;j<=n-3;j++)
printf("%d ",c[j]);
printf("%d %d %d ",d[1],d[2],d[3]);
printf("<BR>);

for(j=1;j<=n-3;j++)
printf("%d ",c[j]);

printf("%d %d %d ",d[1],d[3],d[2]);
printf("<BR>);

t=d[1];d[1]=d[2];d[2]=d[3];d[3]=t;
for(j=1;j<=n;j++)
{
if(c[1] == j) tot[j]++;
}
}
printf("<BR>);
}

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG