c语言删除运动员信息,关于长跑运动员程序的问题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

96a4a13ea64e1613bef5504b346f1632.png

//running.c -- 一个对于长跑运动员有用的程序

#include

const int S_PER_M = 60; //每分钟的秒数

const int S_PER_H = 3600; //每小时的秒数

const double M_PER_K = 0.62137; //每公里的英里数

int main(void)

{

double distk, distm; //分别以公里和英里计跑过的距离

double rate; //以英里 / 小时为单位的平均速度

int min, sec; //跑步用时的分钟数和秒数

int time; //用秒表示的跑步用时

double mtime; //跑完 1英里 所用的时间, 以妙计

int mmin, msec; //跑完 1英里 所用的时间,以分钟和秒计

printf("This program converts your time for a metric race\n");

printf("to a time for running a mile and to your average\n");

printf("speed in miles per hour.\n");

printf("Please enter, in kilometers, the distance run.\n");

scanf("%lf", &distk); //%lf表示读取一个double类型的值

printf("Next enter the time in minutes and seconds.\n");

printf("Begin by entering the minutes.\n");

scanf("%d", &min);

printf("Now enter the seconds.\n");

scanf("%d", &sec);

//把时间转换为全部用秒表示

time = S_PER_M * min + sec;

//把公里转换为英里

distm = M_PER_K * distk;

//把英里/秒 * 秒/小时 = 英里/小时

rate = distm / time * S_PER_H;

//时间/距离 =跑完每英里的用时

mtime = (double)time / distm;

mmin = (int)mtime / S_PER_M; //求出分钟数

msec = (int)mtime % S_PER_M; //求出剩余的秒数

printf("You ran %1.2f km(%1.2f miles) in %d min, %sec.\n",

distk, distm, min, sec);

printf("That pace corresponds to running a mile in %d min, ",

mmin);

printf("%d sec.\nYour average speed was %1.2f mph.\n", msec,

rate);

getch();

return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值