2022.4.15
///* golf.c -- 高尔夫锦标赛记分卡 */
//#include <stdio.h>
//int main()
//{
// int jane, tarzan, cheeta; //简,人猿泰山,猎豹;
//
// cheeta = tarzan = jane = 68;Cheeta =泰山= Jane = 68;
// printf(" cheeta tarzan jane\n");//
// printf("First round score %4d %8d %8d\n", cheeta, tarzan, jane);//printf(“第一轮得分%4d %8d %8d\n”,cheeta, tarzan, jane);
//
// return 0;
//}
cheeta tarzan jane
First round score 68 68 68
cheeta泰山简
第一轮得分68 68 68
///* squares.c -- 计算 1-20 的平方 */
//#include <stdio.h>
//int main()
//{
// int num = 1;
//
// while (num < 21)
// {
// printf("%4d %6d\n", num, num * num);
// num = num + 1;
// }
// return 0;
//}
//
///* wheat.c -- 指数增长 */
//#include <stdio.h>
//#define SQUARES 64 //棋盘中的方格数
//int main()
//{
// const double CROP = 2E16; //世界小麦年产谷粒数
// double current, total; //目前,总;
// int count = 1;
//
// printf("square grains total ");
// printf("fraction of \n");
// printf(" added grains ");
// printf("world total\n"); //printf("世界总\ n ");
// total = current = 1.0; /* 从1颗谷粒开始 */
// printf("%4d %13.2e %12.2e %12.2e\n", count, current, total, total / CROP);
//
// while (count < SQUARES)
// {
// count = count + 1;
// current = 2.0 * current; //下一个方格谷粒翻倍
// total = total + current; /* 跟新总数 */
// printf("%4d %13.2e %12.2e %12.2e\n", count, current, total, total / CROP);
// }
// printf("That`s all.\n");
//
// return 0;
//}
/* divide.c -- 演示除法 */
//#include <stdio.h>
//int main()
//{
// printf("integer division: 5/4 is %d \n", 5 / 4);
// printf("integer division: 6/3 is %d \n", 6 / 3);
// printf("integer division: 7/4 is %d \n", 7 / 4);
// printf("floating division: 7./4 is %1.2f \n", 7. / 4);
// printf("mixed division: 7./4 is %1.2f \n", 7. / 4);
//
// return 0;
//}
/* rules.c -- 优先级测试 */
//#include <stdio.h>
//int main()
//{
// int top, score;
//
// top = score = -(2 + 5) * 6 + (4 + 3 * (2 + 3));
// printf("top = %d, score = %d\n", top, score);
//
// return 0;
//}
//
sizeof.c -- 使用 sizeof 运算符
//#include <stdio.h>
//int main()
//{
// int n = 0;
// size_t intsize;
//
// intsize = sizeof(int);
// printf("n = %d, n has %zd bytes; all ints have %zd bytes.\n", n, sizeof n, intsize);
// return 0;
//}
n = 0, n has 4 bytes; all ints have 4 bytes.
N = 0, N有4个字节; 所有的整数都有4个字节。
min_sec.c -- 把秒数转换成分和秒
//#include <stdio.h>
//#define SEC_PER_MIN 60 // 1分钟60秒
//int main()
//{
// int sec, min, left;
// printf("Convert seconds to minutes and seconds!\n");//printf("将秒转换为分钟和秒! ");
// printf("Enter the number of seconds (<=0 to quit):\n");//printf("输入秒数(<=0退出):\n");
// scanf("%d", &sec); // 读取秒数
// while (sec > 0)
// {
// min = sec / SEC_PER_MIN; //截断分钟数
// left = sec % SEC_PER_MIN; // 剩下的秒数
// printf("%d seconds is %d minutes, %d seconds.\n", sec, min, left);//Printf ("%d seconds is %d minutes, %d seconds. ")。 \n",秒,分钟,左);
// printf("Enter next value (<=0 to quit):\n");//printf("输入下一个值(<=0退出):\n");
// scanf("%d", &sec);
// }
// printf("Done!\n");
//
// return 0;
//}
Convert seconds to minutesand seconds!
Enter the number of seconds(<= 0 to quit) :
2500
2500 seconds is 41 minutes, 40 seconds.
Enter next value(<= 0 to quit) :
将秒转换为分钟和秒!
输入退出的秒数(<= 0) :
2500
2500秒等于41分40秒。
输入下一个值(<= 0退出) :