Cで/*BINFMTC: */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#define max(a,b) ((a) >= (b) ? (a) : (b))int main(int ac, char** av){ int i, sum=0, maxval=0; const char* graphstr="************************************************************************"; int graphstrlen=strlen(graphstr); for (i=1; i<ac; (sum+=atoi(av[i])), ++i, maxval=max(maxval,atoi(av[i]))) if (atoi(av[i])<0) exit(1); for (i=1; i<ac; ++i) printf("%.2i/%.2i %s\n", atoi(av[i]), sum, graphstr+graphstrlen-1-atoi(av[i])*graphstrlen/sum); return 0;}
Re:キミならどう書く 2.0 - ROUND 3 -
Cで
/*BINFMTC:
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define max(a,b) ((a) >= (b) ? (a) : (b))
int main(int ac, char** av)
{
int i, sum=0, maxval=0;
const char* graphstr="************************************************************************";
int graphstrlen=strlen(graphstr);
for (i=1; i<ac; (sum+=atoi(av[i])), ++i, maxval=max(maxval,atoi(av[i]))) if (atoi(av[i])<0) exit(1);
for (i=1; i<ac; ++i)
printf("%.2i/%.2i %s\n", atoi(av[i]), sum, graphstr+graphstrlen-1-atoi(av[i])*graphstrlen/sum);
return 0;
}