(e-mail address removed) said:
Instead of showing C#code, why not describe, in English, the problem you
are trying to solve, and show us your best shot at a C solution?
Once we know what you're trying to do (in English) and how you're trying to
do it (in C), we have a fighting chance of being able tohelpyou achieve
your objective.
--
Richard Heathfield <
http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <
http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Im trying to do the Partation (number theory) to print the results.
this is the closest got using C.
#include<stdio.h>
#include<string.h>
void partation(int n, int m, char str[]);
int main()
{
int no;
printf("Enter a positive integer: ");
scanf("%d",&no);
if(no < 0)
{
printf("%d is not a positive integer.\n",no);
printf("Please enter a positive integer and retry...\n");
return -1;
}
char result[10]="";
partation(no,no,result);
return 0;
}
void partation(int n, int m, char str[])
{
int i;
if(n<m)
i=n;
else
i=m;
if(n>0)
{
for(;i>0;i--)
{
char s[2];
sprintf(s,"%i",i);
strcat(str,s);
partation(n-i,i,str);
}
}
else
{
printf("%s\n",str);
sprintf(str,"");
}
}
In thiscodewhen i input the value 4, i get the result as
4
31
22
11
1111
but the result should be
4
31
22
211
1111
P.S.: Thnkx for ur replies...