格式化输出摄氏华氏温度对应

img

img

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^

供参考:

#include <stdio.h>
int main()
{
    float c=0.0, f=0.0;
    int i,j;
    for(i=-30,j=1;i<=30;i+=5)
    {
        c=(float)i;
        f = 9.0/5.0*c+32;
        if(j==1) printf("%d\t摄氏温度\t华氏温度\n",j++);
        printf("%d\t%8.2f\t%8.2f\n",j++,c,f);
    }
    
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
float c, f;
scanf("%f", &c);
f = 9/5*c+32;
printf("%f" , f);
return 0;
}