Can anyone tell me the Coding for:
Help me!!!
Show what you've done so far.
I guess the following link might help you.
Can anyone tell me the Coding for:
[ATTACH]18596[/ATTACH]
Help me!!!
[ATTACH]18596[/ATTACH]
Help me!!!
I'd be happy to give you complete code so you don't have to do any work at all!
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define f(x) ((x)>0?((x)*((x)+1)/2):0)
#define g(x) (((int)sqrt(8.0*(x)+1)-1)/2)
int main(int c, char **v)
{
if (c>1)
for (c=0;c<f(atoi(v[1]));c++)printf("%s%*s%d",c==f(g(c))?"\n":" ",c==f(g(c))?atoi(v[1])-g(c)-1:0,"",g(c)+1);
return !putchar('\n');
}
There's no need to thank me, I'm here to help. :)
That's disgusting. You could've made it worse by changing all variable names to a multitude of underscores. That would obfuscate it even more ;)
I didn't really want to go full IOCCC style obfuscation. This way it looks ugly, but otherwise reasonable. One might expect to see some of the newbies on Daniweb come up with a program that appears similar at a glance. You'd wonder what the defines are for in such a simple nested loop exercise, and shake your head at the unconventional formatting, but only after a closer look will the fun stuff shine through. :) ...