随笔分类 -  练习

1
学习而练习
摘要:#include<stdio.h>#include<windows.h>int main(void){ FILE*data; data=fopen("C:\\teacher.txt","a");//"a"尾部追加一个“写”的功能 if(!data){ //!data等效于 data == NULL 阅读全文
posted @ 2019-02-19 22:08 指遥 阅读(291) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <windows.h>int main(void){ FILE *a; a=fopen("C:\\student.txt","r"); if(!a){ printf("文件错误!"); }else{ printf("文件打开成功!\n"); sy 阅读全文
posted @ 2019-02-13 15:09 指遥 阅读(160) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void){ FILE*file; file = fopen("C:\\test.txt","a"); if(!file){ printf("文件打开失败!"); } fputs("\n大时代 123456989",file); system(" 阅读全文
posted @ 2019-01-28 14:44 指遥 阅读(147) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>int main(void){ char a[256]; int len,n,i,tem; printf("请输入:\n"); gets(a); printf("%s\n",a); len = strlen(a); n=len/2 阅读全文
posted @ 2019-01-25 11:39 指遥 阅读(177) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(void){ FILE*file; file = fopen("C:\\test","r"); if(!file){ //等效于:file ==NULL printf("打开文件成功!"); }else{ printf("打开文件失败!"); }  阅读全文
posted @ 2019-01-24 15:07 指遥 阅读(2201) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(void){ int n; int i; int num1,num2; int val; printf("请输入斐波那契数列长度:"); scanf("%d",&n); if(n<0){ printf("数值不存在!"); }else if(n== 阅读全文
posted @ 2019-01-24 14:55 指遥 阅读(354) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void){ int a; int b; for(a=1;a<=9;a++){ for(b=1;b<=a;b++){ printf("%d×%d=%d\t",b,a,a*b); } printf("\n"); } return 0;} 阅读全文
posted @ 2019-01-22 13:23 指遥 阅读(160) 评论(0) 推荐(0)
摘要:/*遇到问题:1、编译过程中无法编译,需要用C99,解决方法: -std=c99 2、for循环:不加分号“;”,写错编译器可以通过编译但输出数据和理想中不符合 错误写法:for(;;;);{ } 正确写法:for(;;;){ } */ #include <stdio.h>int main(void 阅读全文
posted @ 2019-01-22 13:07 指遥 阅读(667) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <windows.h>int main(void){ int a; //定义一个整数型变量 for(a=1;a<8;a++){ printf("天上有%d颗星星!\n",a); Sleep(1000); //休眠1000毫秒=1秒,Windows 阅读全文
posted @ 2019-01-20 21:19 指遥 阅读(241) 评论(0) 推荐(0)
摘要:#include <stdio.h>//打印成绩//0-59,不及格//60-79,及格//80-94,良好//95-100,优秀//其他,非法数据int main(void){ int score; //这个是int整数型,定义char型会出错 //加了while(1)函数,无限循环,按“ctrl 阅读全文
posted @ 2019-01-20 20:04 指遥 阅读(174) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void){ int tmp; printf("今天的天气是多少度?\n"); scanf("%d",&tmp); if(tmp>16 ){ printf("出行!\n"); } return 0;} #include <stdio.h>#inc 阅读全文
posted @ 2019-01-19 14:08 指遥 阅读(251) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void){ int xc; int zv; printf("请输入 :"); scanf("%d",&xc); printf("请输入:"); scanf("%d",&zv); if (xc >= 100 && zv >= 10) { prin 阅读全文
posted @ 2019-01-14 13:52 指遥 阅读(132) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>int main(void){ char min[32] = "love"; char mic[32]; int ad; printf("请输入:"); fgets(mic,sizeof(mic),stdin); ad = s 阅读全文
posted @ 2019-01-14 13:28 指遥 阅读(178) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>int main(void){ char min[32] = "love"; char mic[32]; int ad; printf("请输入:"); gets(mic); //通过顺序比较,通过的ASCII码大小来判断输出 阅读全文
posted @ 2019-01-13 21:25 指遥 阅读(197) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void)/*通过数组来实现5个整数的平均值*/{ int data[64]; float average; printf("请输入5个整数:"); scanf("%d%d%d%d%d",&data[0], &data[1],&data[2],& 阅读全文
posted @ 2019-01-11 12:41 指遥 阅读(1361) 评论(0) 推荐(0)
摘要:/*#include <string.h> 1、strlen 计算字符串长度; 2、strcop 拷贝; 3、strncop 拷贝指定数量的字符; 4、shrcat 连接字符串;*/ #include <stdio.h>#include <string.h>int main(void){ char 阅读全文
posted @ 2019-01-10 14:10 指遥 阅读(287) 评论(0) 推荐(0)
摘要:/*scanf输入的数据中有’空格‘或’回车符‘的时候编译器只执行到空格或回车符之前的数据。 gets输入可以执行有空格或回车符的数据,但数据超过输入限制编译器也不会提示,用gets输入容易越界输入。 fgets输入可以防止越界输入。 #include <stdio.h>int main(void) 阅读全文
posted @ 2019-01-09 13:03 指遥 阅读(621) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main(void) { char my[ ]="love"; printf("my %s",my); return 0;} #include <stdio.h>int main(void){ char my[7]; my[0]='l'; my[1]=' 阅读全文
posted @ 2019-01-08 13:21 指遥 阅读(253) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void){ int a[8]={1,3,5,7,9,2,4,6}; printf("%d,%d,%d,%d,%d,%d,%d,%d", a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]); return 0;} # 阅读全文
posted @ 2019-01-07 14:12 指遥 阅读(294) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(void){ char a; char red; printf("请输入一个小写字母:"); scanf("%c",&a); red = a - 32; printf("%c的大写字母是:%c",a,red); return 0; } ***** 阅读全文
posted @ 2019-01-05 19:35 指遥 阅读(439) 评论(0) 推荐(0)

1