- 博客(11)
- 收藏
- 关注
原创 复制输入到输出将其中的制表符替换为\t
#include main(){ char c; while((c=getchar())!=EOF){ if(c=='\t'){ printf("\ \\t"); //好气啊,打了一堆心得突然间 //通不过编译了!重新打代码又好了, //有大佬知道啥情况吗? /*'\'前面提到过是告诉编译器代码延续 到下一行‘\t’是字符串常量。我这么 理解应该对吧?上面代码等同于 pr
2016-12-16 03:01:06
878
转载 关于空格代替程序后续
#include void main() { int c,n1; n1=0; while((c=getchar()) !='#') { if(c!=' ') { n1=0; putchar(c); }
2016-12-16 02:56:20
335
原创 单个空格代替多个空格
/*编写一个将输入复制到输出的程序,并将其中连续 的多个空格用一个空格代替*/ #include main(){ char c; int i=1; while((c=getchar())!=EOF){ if(c!=' '){ i=1;putchar(c); } else if(i==1){/*又把‘==’ 打成‘=’了一直找不到错误!*/ i=0;pu
2016-12-16 02:54:55
460
原创 统计字符行数空格换行制表符个数
#include main(){ int i,j,n,c,t; for(i=0,j=0,n=0,t=0;(c=getchar())!=EOF;n++){ if(c=='\n') i++; if(c==' ') j++; if(c=='\t') t++; }/*小心别把'=='打成'='程序可以运行全部都显示的字符数*/ printf("字符数是%d\t行数是%d\t空格数是%d\
2016-12-16 02:52:27
831
转载 字符计数
#include main(){ char c; long i; for(i=0;(c=getchar())!=EOF;i++) ; printf("%ld",i);/*可以用 double i;" %.0f""处理更大的数*/ return 0; }
2016-12-16 02:49:48
500
转载 用宏表示π的值
#include #include main(){ printf("%f",M_PI); /*可以在开头定义为常量 #define PI M_PI*/ } #include #include #define PI M_PI main(){ printf("%f",PI); }
2016-12-15 05:53:41
949
转载 求π的近似值
#include /*分数:fractions分子:numerator分母:denominator*/ main(){ double sum,sign,i,s; sum=1.0;i=1.0;s=1.0; for(;1/i>1e-6;i=i+2.0){ sign=1.0/(i+2.0); s=-s;/*技巧用单独的一个变量控制+ -*/ sum=sum+sign*s; }
2016-12-15 05:51:28
1739
转载 华氏摄氏温度对照表
#include #define lower 0 #define upper 300 #define step 20 main(){ int i; for(i=lower;i printf("%d\t%.2f\n",i,(5.0/9.0)*(i-32)); /*华氏摄氏对应转换公式C=(5/9)*(F-32) celeius fahr*/ return 0; }
2016-12-15 05:44:53
3327
转载 箱子的空间中量
#include main(){ int length,width,height; int weight,volume; scanf("%f%f%f",&width,&height,&length); volume=length*height*width; weight=(volume+165)/166;/*这里的+165精髓*/ printf("%d",volume); retu
2016-12-15 05:43:28
264
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅