user-0 提问: 各位帮看看

回复:
user: user-0
content: 引用 3 楼 cfjtaishan 的回复:[quote=引用 2 楼 weixin_37671669 的回复:] [quote=引用 1 楼 cfjtaishan 的回复:] #include<stdio.h>  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;     int mmin,msec;      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 disatance run.\n");     scanf("%lf",&distk);     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("Your ran %1.2f km (%1.2f miles) in %d min, %d sec.\n",distk,distm,min, sec);  /*少一个%d*/     printf("Thaat  pace corresponds to running a mile in %d min,", mmin);     printf("%d sec.\nYour average speed was %1.2f mph.\n",msec, rate);     return 0; } 少了一个%d其他没发现问题。 建议：全局变量能用宏定义的可以考虑使用宏。全局面量命名建议使用类似gmin_per_m，g标识global 感谢 使用全局变量的名字，有哪些要求么？[/quote] 主要是见名知义就好，局部变量也是。命名方法有多种，比如camel命名法 另外，自己代码风格也建议改改，详尽的coding style.可以参考Linux内核的[/quote]  感谢哦

user: user-1
content: 引用 2 楼 weixin_37671669 的回复:[quote=引用 1 楼 cfjtaishan 的回复:] #include<stdio.h>  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;     int mmin,msec;      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 disatance run.\n");     scanf("%lf",&distk);     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("Your ran %1.2f km (%1.2f miles) in %d min, %d sec.\n",distk,distm,min, sec);  /*少一个%d*/     printf("Thaat  pace corresponds to running a mile in %d min,", mmin);     printf("%d sec.\nYour average speed was %1.2f mph.\n",msec, rate);     return 0; } 少了一个%d其他没发现问题。 建议：全局变量能用宏定义的可以考虑使用宏。全局面量命名建议使用类似gmin_per_m，g标识global 感谢 使用全局变量的名字，有哪些要求么？[/quote] 主要是见名知义就好，局部变量也是。命名方法有多种，比如camel命名法 另外，自己代码风格也建议改改，详尽的coding style.可以参考Linux内核的

user: user-0
content: 引用 1 楼 cfjtaishan 的回复:#include<stdio.h>  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;     int mmin,msec;      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 disatance run.\n");     scanf("%lf",&distk);     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("Your ran %1.2f km (%1.2f miles) in %d min, %d sec.\n",distk,distm,min, sec);  /*少一个%d*/     printf("Thaat  pace corresponds to running a mile in %d min,", mmin);     printf("%d sec.\nYour average speed was %1.2f mph.\n",msec, rate);     return 0; } 少了一个%d其他没发现问题。 建议：全局变量能用宏定义的可以考虑使用宏。全局面量命名建议使用类似gmin_per_m，g标识global 感谢 使用全局变量的名字，有哪些要求么？

user: user-1
content: #include<stdio.h>  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;     int mmin,msec;      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 disatance run.\n");     scanf("%lf",&distk);     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("Your ran %1.2f km (%1.2f miles) in %d min, %d sec.\n",distk,distm,min, sec);  /*少一个%d*/     printf("Thaat  pace corresponds to running a mile in %d min,", mmin);     printf("%d sec.\nYour average speed was %1.2f mph.\n",msec, rate);     return 0; } 少了一个%d其他没发现问题。 建议：全局变量能用宏定义的可以考虑使用宏。全局面量命名建议使用类似gmin_per_m，g标识global