C语言的文件作用域?

C语言的文件作用域是作用于一个文件还是多个文件?
C | 2020-12-31 22:11 | 阅读 1473 次 | 评论 2 条

C PRIMER PLUS 第六版 P372 第15题

15.使用字符分类函数实现atoi()函数。 如果输入的字符串不是纯数字,该函数返回0。 #include<stdio.h> int catoi(char*); int main(void) { char ch[100]; int tot; printf("please input:"); gets(ch); tot=catoi(ch); printf("the number:%d",tot); return 0; } int catoi(char*s) { int i=0; int sum=0; ...
默认分类 | 2020-12-14 21:27 | 阅读 1260 次 | 评论 0 条

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 | 阅读 1230 次 | 评论 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 | 阅读 1232 次 | 评论 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 | 阅读 1289 次 | 评论 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 | 阅读 1606 次 | 评论 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 | 阅读 1191 次 | 评论 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 | 阅读 1247 次 | 评论 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 | 阅读 1665 次 | 评论 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 | 阅读 1253 次 | 评论 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 | 阅读 1114 次 | 评论 0 条

bool .c .cpp

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

头文件h

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

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 | 阅读 1819 次 | 评论 0 条

C C C

C语言看了一段时间,感觉没啥进步,都在原地踏步,啥时候能有所突破呢。唉.....
默认分类 | 2020-04-26 21:10 | 阅读 733 次 | 评论 1 条

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

#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 | 阅读 3932 次 | 评论 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 | 阅读 2150 次 | 评论 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 | 阅读 1894 次 | 评论 0 条
浏览34950次