Ajinkya said:
Please dont say that to me....there are ACM ICPC winners on the group
who post regularly.
If they're that good, why doesn't their code compile and work properly?
First example I found:
#include <stdio.h>
#include <conio.h>
int main()
{
int TotalSteps=0,NoOfTwoSteps,NoOfOneSteps,TotalWays=1;
int i;
printf ("\nPlease enter the number of steps: ");
scanf ("%d",&TotalSteps);
NoOfTwoSteps=TotalSteps/2;
for (i=1;i<=NoOfTwoSteps;i++)
{
int Factorial1,Factorial2,Factorial3;
int TotalStep,j;
NoOfOneSteps = TotalSteps - i * 2;
Factorial1=Factorial2=Factorial3=1;
for (j=2;j<=NoOfOneSteps+i;j++)
Factorial1*=j;
for (j=2;j<=NoOfOneSteps;j++)
Factorial2*=j;
for (j=2;j<=i;j++)
Factorial3*=j;
TotalStep = Factorial1/(Factorial2*Factorial3);
TotalWays+=TotalStep;
}
printf("\nTotal Ways are: %d",TotalWays);
getch();
return 0;
When we compile this, we get:
foo.c:2: conio.h: No such file or directory
make: *** [foo.o] Error 1
Removing that line, we get:
foo.c:4: warning: function declaration isn't a prototype
foo.c: In function `main':
foo.c:46: warning: implicit declaration of function `getch'
foo.c:49: parse error at end of input
make: *** [foo.o] Error 1
When we remove the getch and fix the missing brace, we get a program
which behaves thusly:
me@here> ./foo
Please enter the number of steps: ELEPHANT
Total Ways are: 1me@here>
Not good.