fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n, i=0;
  5. float f;
  6. char c[2];
  7. scanf("%d",&n);
  8. while(i++<n){
  9. scanf("%f%s",&f, c);
  10. printf("%d ", i);
  11. if(c[0]=='k') printf("%.4f lb\n", f*2.2046);
  12. else if(c[0]=='g') printf("%.4f l\n", f*3.7854);
  13. else if(c[1]=='b') printf("%.4f kg\n", f*0.4536);
  14. else printf("%.4f g\n", f*0.2642);
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 2296KB
stdin
5
1 kg
2 l
7 lb
3.5 g
0 l
stdout
1 2.2046 lb