C PRIMER PLUS 6 P276 第七题

#include <stdio.h> #include <string.h> #include <ctype.h> int letter(char); int main() { char ch; int i; while((ch=getchar())!=EOF) { if(i%10==0)printf("\n"); printf("%c=%d\t",ch,letter(ch)); i++; } return 0; } int letter(char ch) { int a; a=isalpha(c...
练习题 | 2020-11-24 21:56 | 阅读 1233 次 | 评论 0 条

C PRIMER PLUS 6 P276 第六题

#include <stdio.h> #include <string.h> void large(double*,double*,double*); int main() { double first,second,third; printf("input first:"); scanf("%lf",&amp;first); printf("input second:"); scanf("%lf",&amp;second); printf("input third:"); scanf("%lf",&amp;third);...
练习题 | 2020-11-24 21:39 | 阅读 1291 次 | 评论 0 条

小练笔

编写程序,计算使用某快递公司运输货物的运费(用if语句)。 要求: 1)显示目的城市列表,通过输入需要选择城市。 2)输入货物重量 3)根据运费价格表来计算运费,其中首重费用为1kg以内的费用,超过1kg的部分每公斤使用续重费用计算。 4)1kg内的总运费=首重费用 大于1kg的总运费=首重费用+(重量-1)*续重 城市 费用 广东 首重8元,续重2元 上海 首重9元,续重7元 北京 首重12元,续重10元 东三省 首重15元,续重13元 #include <stdio.h> #include <string.h> ...
练习题 | 2020-11-23 19:54 | 阅读 1610 次 | 评论 0 条

C PRIAMER PLAS 第六版 P276 第三题

#include <stdio.h> void small(char,int,int); int main(void) { int x,y; char ch; printf("zifu:"); ch=getchar(); printf("lie:"); scanf("%d",&amp;y); printf("lines:"); scanf("%d",&amp;x); small(ch,x,y); return 0; } void small...
练习题 | 2020-11-22 21:50 | 阅读 1193 次 | 评论 0 条

CPRIMERPLUS6 P242 第4题

#include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { int ch=0; int up=0,a=0,b=0; int count=0,let=0; double pj; while((ch=getchar())!=EOF) { a=isalpha(up); if(a)a=1; b=isalpha(ch); if(b){b=1;let++;} if(a==0&amp;&amp;b==1)count++; up=ch; } ...
练习题 | 2020-11-21 11:56 | 阅读 1248 次 | 评论 0 条

CPRIMERPLUS6 P216 第11题

#include <stdio.h> #define pyj 2.05 /* 洋蓟:2.05美元/磅 */ #define ptc 1.15 /* 甜菜:1.15美元/磅 */ #define phlb 1.09 /*胡萝卜:1.09美元/磅 */ #define b100d 100 /*100美元订单有5%的优惠*/ #define yhu 0.05 /*100美元订单有5%的优惠*/ #define b5b 5 /*5磅以内收取6.5美元的运费和包装费*/ #define yubf0 6.5 /*5磅以内收取...
练习题 | 2020-11-19 21:51 | 阅读 1667 次 | 评论 0 条

CPRIMERPLUS6 P215 第10题

#include <stdio.h> //#include <string.h> #define sin 17850 #define huz 23900 #define yig 29750 #define yil 14875 #define ftax 0.15 #define stax 0.28 void menu(void); void star(int i); double single(int doll,int base); double huzhu(int doll); int main(void) { char c...
练习题 | 2020-11-18 21:57 | 阅读 1255 次 | 评论 0 条

CPRIMERPLUS6 P215 第九题

#include <stdio.h> bool sushu(int num); int main(void) { int num; printf("input:"); scanf("%d",&amp;num); if(num<=0)printf("sorry"); for(int i=3;i<=num;i++) { if(sushu(i)==1) printf("%d\t",i); } return 0; } bool sushu(int num) { bool judge=true; for(int i=2;i<num...
练习题 | 2020-11-18 20:56 | 阅读 1115 次 | 评论 0 条

bool .c .cpp

今天发现一个小秘密: 写代码时使用了bool类型,奇怪的是,编译报错,前两天我在另一台电脑都使用正常啊,为什么呢,经过一番上网搜索,终于发现,在DEV C++里,如果源程序扩展名是 .c 则编译报错,如果扩展名是 .cpp,则编译通过,理由是,.c,编译器则按C语言编译,而C语言没有bool类型。.cpp 编译器则按C++语言编译,C++有 bool 类型。
C | 2020-11-16 17:27 | 阅读 1560 次 | 评论 5 条

C primer plus P175 第五题 金字塔

#include <stdio.h> int main(void) { char ch; bool boo; do { boo=true; printf("Input:"); scanf("%c",&amp;ch); if(ch=15) scanf("%c",&amp;ch); if(ch<'A' or ch>'Z') { printf("error! re-input please\n"); boo=false; } }while(!bo...
练习题 | 2020-11-15 15:07 | 阅读 1215 次 | 评论 0 条

华氏摄氏开氏 C primer plus 第五章第九题

#include <stdio.h> #define shehua 5.0/9.0 void temperatrues(double ccc); const int a=32; int main(void) { double hua; printf("input hua:"); while(scanf("%lf",&amp;hua)) { temperatrues(hua); printf("input hua:"); } printf("finish"); return 0; } void temperatrues(do...
练习题 | 2020-11-14 15:28 | 阅读 1198 次 | 评论 0 条

头文件h

#include <stdio.h> //printf(); //scanf() 如果是1个参数,成功读取,返回1,如果是两个参数,成功读取,返回2,如果读取不成功,返回0; //gets() 读取字符串,并且舍弃换行。常于puts()配对使用。 //puts(地址) 只显示字符串,而且自动在显示的字符串末尾加上换行符。 //fgets(目标字符串数组,大小,设备) 读取字符串,末尾加上换行符,可以从不同设备读取,如键盘(stdin)、文件等,该函数只读取 大小-1 个字符 //fputs(要输出的字符串数组,设备) 显示字符串...
C | 2020-11-14 11:48 | 阅读 1504 次 | 评论 2 条
浏览34999次