multiply SI units by rolf

#include<stdio.h>
#define A if(strcmp(b,a[j])==0)
int main()
{
int s,i,j,c,l,h;
char *a[99],r[99],b[99],*L=0,*o[7]={"m","kg","s","A","K","mol","cd"};
for(;;)
{
if(getline(&L,&l,stdin)==-1)break;
l=strlen(L)-1;
if(L[l]=='\n')L[l]=0;
s=0;a[0]=strtok(L," ");*r=0;h=0;
while(a[s])a[++s]=strtok(0," ");
for(i=0;i<7;i++)
{
c=0;
for(j=0;j<s;j++)
{
strcpy(b,o[i]);
A c+=1;
strcat(b,"2");
A c+=2;
}
if(c)
{
if(h)strcat(r," ");
strcat(r,o[i]);
sprintf(b,"%d",c);
if(c>1)strcat(r,b);
h=1;
}
}
printf("%s\n",r);
}
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

To protect the system from spam, please input your favorite sport (hint: I believe its name must start with 'g', case insensitive)

download

return to the top page