8.1 重复 输入 8.1 echo.c -- 重复 输入#include <stdio.h>int main(void){ char ch; while ((ch = getchar()) != '#') putchar(ch); return 0;}转载于:https://www.cnblogs.com/EisNULL/p/10828...
8.12.5 # 8.12.5#include <stdio.h>int main(void){ int rangebig, rangesmall, input; int defaultnum = 67;// scanf("%d", &input); while(scanf("%d", &input)) { ...
8.11.4.c 如果有超过2个连续的非字母出现则单词计数不准确。# 8.11.4.c#include <stdio.h>#include <ctype.h>int main(void){ int word = 0, ch_total = 0, nocharflag = 0; char ch; while ((ch = getchar(...
8.11.3 统计大小写字符个数 # 8.11.3.c#include <stdio.h>#include <ctype.h>int main(void){ char ch; int upper = 0, lower = 0, total = 0; while ((ch = getchar()) != EOF) { ++total; ...
8.10.8 使用getchar函数之前记得处理换行符 # 8.10.8#include <stdio.h>int main(void){ printf("使用getchar函数之前记得处理换行符"); putchar(''); printf("在使用缓冲输入的系统中,"); printf("把数值和字符混合输入会遇到"); printf("什么潜在问题?"); put...
8_8 menuette.c 8_8 menuette.c -- 菜单程序#include <stdio.h>char get_choice(void);char get_first(void);int get_int(void);void count(void);int main(void){ int choice; void count(void); while...
8.7 checking.c // checking.c -- 输入验证#include <stdio.h>#include <stdbool.h>// 验证输入是一个整数long get_long(void);// 验证范围的上下限是否有效bool bad_limits(long begin, long end, long low, long hi...
7.12.11 蔬菜计算器 # 7.12.11#include <stdio.h>#define artichoke 2.05#define beet 1.15#define carrot 1.09#define discount 0.95int main(void){ double partichoke, sum_artichoke_pound = 0; ...
8.4 一个拖沓且错误的猜数字程序 8.4 guess.c -- 一个拖沓且错误的猜数字程序#include <stdio.h>int main(void){ int guess = 1; printf("Pick an integer from 1 to 100. I will try to guess "); printf("it. Respond with a y if ...
断网,启用网络,关机的实现。 windows 下实现 shutdown_two.c 此为第三版 // 我需要一个断开网络,启用网络,定时发送邮件后关机的功能,其中定时发送邮件功能是邮件客户端完成;原来的工具是用bat实现的,后来给BAT内容放到C中,延时部分用的还是 choice ,因此需要手工输入延时时间。 // 后来想做个自动计算时间的方法,后来发现sleep用这个功能,遂写了这个功能。说个小...
8.3 打开一个文件并显示该文件 8.3 file_eof.c -- 打开一个文件并显示该文件#include <stdio.h>#include <stdlib.h> // 为了使用exit()int main(){ int ch; FILE *fp; char fname[50]; // 存储文件名 printf...
8.2 重复输入,直到文件结尾 echo_eof.c -- 重复输入,直到文件结尾#include <stdio.h>int main(void){ int ch; while ((ch = getchar()) != EOF) // Ctrl + Z 结束符 putchar(ch); return 0;}转载于:https://w...
7.12.9 显示所有小于或等于该数的素数。 #7.12.9#include <stdio.h>int main(void){ int num; int i , j; int flag = 0; printf("请输入一个正整数:"); if ((scanf("%d", &num) == 1) && (num > 0)) { ...
7.12.10 计算税金 # 7.12.10#include <stdio.h>#define big_rate 0.28#define sml_rate 0.15#define single 17850#define god 23900#define mar_two 29750#define mar_one 14875int main(void){ float earni...
7.12.8 # 7.12.8#include <stdio.h>#define over_time 1.5 * 10#define three_hundred_rate 0.15#define one_hundred_half_rate 0.2#define more_then_four_hun_half_rate 0.25#define three_hundr...
7.12.8 # 7.12.8#include <stdio.h>#define over_time 1.5 * 10#define three_hundred_rate 0.15#define one_hundred_half_rate 0.2#define more_then_four_hun_half_rate 0.25#define three_hundre...
7.12.7 # 7.12.7#include <stdio.h>#define basic_wage 10.00#define over_time 1.5 * 10#define three_hundred_rate 0.15#define one_hundred_half_rate 0.2#define more_then_four_hun_half_rate ...
7.12.6 # 7.12.6#include <stdio.h>int main(void){ char ch; char prechar; int frequency = 0; while ((ch = getchar()) != '#') { if (ch == 'e') prechar = '...
7.12.4 # 7.12.4#include <stdio.h>int main(void){ int Exclamationtoperiod = 0; // 感叹号替换句号次数 int two2one = 0; // 两个感叹号替换一个感叹号次数 char ch; while ((ch = getchar()) !=...
7.12.5 # 7.12.4#include <stdio.h>int main(void){ int Exclamationtoperiod = 0; int two2one = 0; char ch; while ((ch = getchar()) != '#') { switch (ch) { ...