CPRIMERPLUS 6 P372 第十三题

13.编写一个程序, 反序显示命令行参数的单词。 例如, 命令行参数是see you later, 该程序应打印later you see #include<stdio.h> #include<string.h> #include<ctype.h> void st(char**,int); int main(int argc,char *argv[]) { //printf("%d\n",argc); for(int i=1;i<argc;i++) { puts(argv[i]); } st(argv,argc); ret...
2020-12-13 21:51 | 阅读 1231 次 | 评论 0 条

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 | 阅读 1290 次 | 评论 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 | 阅读 1609 次 | 评论 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 | 阅读 1192 次 | 评论 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 | 阅读 1254 次 | 评论 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 条

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 条

C primer plus第六版 P371 第十题

//求字符串长度 #include <stdio.h> int strlenc(char *); int main(void) { char a[100]={0}; puts("please input:"); scanf("%s",a); puts(a); printf("这个字符串长度为(一个汉字是两个字符):%d",strlenc(a)); ...
2020-05-27 21:13 | 阅读 1820 次 | 评论 0 条

小练习:求身份证最后一位

#include <stdio.h> int main(void) { char id[17]; int idx[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; char last[11]={'1','0','X','9','8','7','6','5','4','3','2'}; int sum=0,i; printf("Please input ID:"); for (int i=0;i<17;i++) { scanf("%c",&amp;id[i]); //printf("%c",id[i]); ...
2020-04-23 22:06 | 阅读 3934 次 | 评论 12 条

C语言程序设计现代方法第二版P196页第9题和第12题

第9题: #include <stdio.h> double inpr(const double*a,const double*b,int n); int main(void) { double a1[3]={1.1,2.2,3.3}; double b1[3]={4.4,5.5,6.6}; printf("%.2f",inpr(a1,b1,3)); return 0; } double inpr(const double*a,const double*b,int n) { const double *...
2020-04-12 16:45 | 阅读 2154 次 | 评论 1 条

C语言程序设计现代方法第二版P182第六题

#include <stdio.h> #define N 10 void ftl(int [],int,int*,int*); int main(void) { //int a[N]={1,287,100,92,287,920,56,98,24,88}; int big,big2; for(int i=0;i<N;i++) { printf("a[%d]==",i); scanf("%d",&amp;a[i]); } ftl(a,N,&amp;big,&amp;big2); printf("\n\n\n1st==%d...
2020-04-11 11:34 | 阅读 1895 次 | 评论 0 条

C语言程序设计现代方法第二版P152第10题

#include <stdio.h> void ar1(int[],int); int main(void) { int a[13]={5,-9,3,0,-4,8,-1,7,6,2,-1000}; ar1(a,10); printf("最大数为:%d\n",a[10]); printf("\n平均值为:%.2f\n",(double)a[11]/10); printf("\n正整数共有 %d 个" ,a[12]); return 0; } void ar1(int a[],int n) { for(int i=0;...
2020-04-04 21:01 | 阅读 1958 次 | 评论 0 条
浏览34987次