Prints a table of conversions from inches to centimeters at every half inch. 半インチ毎のインチ〜センチメートルの変換表を表示する。

Format
Plain text
Post date
2014-02-14 22:29
Période de publication
Illimité
  1. /* Working up a shoe size conversion chart.
  2. // 靴サイズの変換を表にまとめましょう。
  3. // By Joel Rees, February 2014.
  4. // ジョエル リースの2014年2月作。
  5. // Play with it, check out your compiler and your understanding.
  6. // これを使ってコンパイラの動作や自分の理解度をご確認ください。
  7. // いじってみて下さい。
  8. */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. int main( int argCount, char * arguments[] )
  12. {
  13. double start = 5; /* inches */
  14. double end = 13.6;
  15. double step;
  16. if ( argCount > 2 )
  17. {
  18. start = strtod( arguments[ 1 ], NULL );
  19. end = strtod( arguments[ 2 ], NULL );
  20. }
  21. printf( "%7s -- %7s\n", "inches", "cm" );
  22. for ( step = start; step < end; step = step + 0.5 )
  23. { printf( "%7.1f .. %7.1f\n", step, step * 2.54 );
  24. }
  25. return EXIT_SUCCESS;
  26. }
Télécharger Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text