1172 Problem U "C Programming Language" Jiang Po Kushiro Editor - Exercises 6-1- temperature conversion

Problem Description

Programming an output Celsius - Fahrenheit conversion table Celsius value interval is input from the keyboard, temperature interval 10 ℃. And function calls defined in claim ctof ©, the temperature in degrees Fahrenheit is converted to F, is calculated: F = 32 + c * 9 /5.
Note: When this problem done with C language, just submit header files and ctof (int c) function, the system will automatically append the following main functions running, please copy the following main functions used for debugging ctof function.
The answer is not required by other languages.

int main(){
      int i,start,end;
     scanf("%d%d",&start,&end);
      for(int i=start;i<=end;i+=10){
             printf("%dC=%dF\n",i,ctof(i));
      }
      return 0;
}

Entry

Start-stop temperature conversion table

Export

Conversion table

Sample input

10 20

Sample Output

10C=50F
20C=68F

AC Code

#include <stdio.h>

using namespace std;


int ctof(int num)
{
    return 32+num*9/5;
}

int main(){

    int i,start,end;

    scanf("%d%d",&start,&end);

    for(int i=start;i<=end;i+=10){

        printf("%dC=%dF\n",i,ctof(i));
    }
    return 0;

}

Published 119 original articles · won praise 28 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_41179709/article/details/103970199