C表示摄氏温度和随机数生成输出的问题

来源:互联网 发布:如何批量注册淘宝小号 编辑:程序博客网 时间:2024/04/28 10:46
输入华氏温度,输出相应的摄氏温度。公式:C=5×(F-32)/9,其中C表示摄氏温度,F表示华氏温度?

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



利用随机数函数依次生成5个100—200(含100,200)之间的随机数并输出?
#include <stdlib.h>#include <stdio.h>#include <time.h>int main(void){   int i;   time_t t;   srand((unsigned) time(&t));   printf("Ten random numbers from 100 to 200\n");   for(i=0; i<5; i++)       printf("%d\n", rand() % 100+100);   return 0;}


0 0
原创粉丝点击