I created two programs and I do not know which is faster
I have two generators of wps codes:
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
int num=0;
for(;num<99999999;++num)
{
if(num<10)
fprintf(stdout, "0000000%d\n", num);
else if(num<100)
fprintf(stdout,"000000%d\n", num);
else if(num<1000)
fprintf(stdout, "00000%d\n", num);
else if(num<10000)
fprintf(stdout, "0000%d\n", num);
else if(num<100000)
fprintf(stdout, "000%d\n", num);
else if(num<1000000)
fprintf(stdout, "00%d\n", num);
else if(num<10000000)
fprintf(stdout, "0%d\n", num);
}
}
Two:
Code:
#include <stdio.h>
int main()
{
char str[11];
double num=0;
for(int i=0; i<=99999999; i++)
{
snprintf(str, 11, "%.8f", num);
for(int a=2; a<=11; a++)
putchar(str[a]);
putchar('\n');
num+=0.0000001;
}
}
The second code on my phone works faster.
I'm looking for volunteers who measure the speed of execution of these two codes and write here about the results. I make the program and I need the fastest solution, so I ask for your help!