随笔分类 -  c/c++

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 30 下一页
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; double a[10] = {1.1,2.1,3.1,4.1,5.1,6.1,7.1,8.1,9.1,0.1}; int i; for(i = 0; i < 10; i++) { printf("a[ 阅读全文
posted @ 2021-06-09 18:28 小鲨鱼2018 阅读(47) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; // 定义指向FILE型的指针变量 double pi = 3.14159265358979323846; printf("Pi from value: %23.21f.\n", pi); // 直接输 阅读全文
posted @ 2021-06-09 17:32 小鲨鱼2018 阅读(332) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; // 声明指向FILE型的指针变量 double pi = 3.14159265358979323846; //声明 double型变量 printf("pi from value: %23.21f.\ 阅读全文
posted @ 2021-06-09 17:11 小鲨鱼2018 阅读(967) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <ctype.h> int main(void) { int ch; FILE *sfp; FILE *dfp; char sfile[FILENAME_MAX]; char dfile[FILENAME_MAX]; printf("sf 阅读全文
posted @ 2021-06-09 09:39 小鲨鱼2018 阅读(50) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <ctype.h> int main(void) { int ch; FILE *sfp; FILE *dfp; char sfile[FILENAME_MAX]; char dfile[FILENAME_MAX]; printf("sf 阅读全文
posted @ 2021-06-09 09:30 小鲨鱼2018 阅读(33) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { int ch; FILE *sfp; FILE *dfp; char sfile[FILENAME_MAX]; char dfile[FILENAME_MAX]; printf("sfile name: "); scanf 阅读全文
posted @ 2021-06-09 09:10 小鲨鱼2018 阅读(41) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; int ch; char filename[FILENAME_MAX]; printf("filename: "); scanf("%s", filename); if((fp = fopen(file 阅读全文
posted @ 2021-06-09 08:07 小鲨鱼2018 阅读(47) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; int ch; char filename[FILENAME_MAX]; printf("please input filename: "); scanf("%s", filename); if((fp 阅读全文
posted @ 2021-06-08 22:50 小鲨鱼2018 阅读(59) 评论(0) 推荐(0)
摘要:c语言中显示文件内容。 1、 #include <stdio.h> int main(void) { FILE *fp; // 定义FILE型的指针变量,用于接收fopen函数返回的流指针 int ch; // 声明字符,注意是int char filename[FILENAME_MAX]; // 阅读全文
posted @ 2021-06-08 22:29 小鲨鱼2018 阅读(635) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <time.h> char filename[] = "timedata.dat"; void put_dat(void) { FILE *fp; if((fp = fopen(filename, "r")) == NULL) print 阅读全文
posted @ 2021-06-08 18:18 小鲨鱼2018 阅读(90) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <time.h> char file[] = "datatime.dat"; void put_data(void) { FILE *fp; if((fp = fopen(file,"r")) == NULL) // 未检测到datati 阅读全文
posted @ 2021-06-08 17:42 小鲨鱼2018 阅读(292) 评论(0) 推荐(0)
摘要:c语言中写入日期和时间。 1、 #include <stdio.h> #include <time.h> int main(void) { FILE *fp; time_t current = time(NULL); struct tm *timer = localtime(&current); i 阅读全文
posted @ 2021-06-08 12:39 小鲨鱼2018 阅读(1096) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <time.h> // time_t数据类型,日历时间头文件 int main(void) { time_t current = time(NULL); // 利用time函数获取日历时间(返回1970之后的秒数,整型) struct t 阅读全文
posted @ 2021-06-08 12:28 小鲨鱼2018 阅读(2220) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #define NUMBER 6 typedef struct{ char name[128]; double height; double weight; }Type1; int main(void) { FILE *fp; fp = fopen("xx 阅读全文
posted @ 2021-06-07 21:45 小鲨鱼2018 阅读(64) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #include <string.h> typedef struct{ char name[128]; double height; double weight; }Type1; void swap2(Type1 *x, Type1 *y) { Type1 阅读全文
posted @ 2021-06-07 19:01 小鲨鱼2018 阅读(49) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> typedef struct{ char name[128]; double height; double weight; }Type1; void swap(Type1 *x, Type1 *y) { Type1 tmp = *x; *x = *y; * 阅读全文
posted @ 2021-06-07 18:44 小鲨鱼2018 阅读(39) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> typedef struct{ char name[128]; double height; double weight; }Typex; void swap(Typex *x, Typex *y) { Typex tmp = *x; *x = *y; * 阅读全文
posted @ 2021-06-07 16:25 小鲨鱼2018 阅读(36) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> #define NUMBER 5 void sort(int x[], int n) { int i, j; // i表示具体循环的轮数, j表示每一轮参与比较的元素的下标 for(i = 0; i < n - 1; i++)//一共循环的轮数n - 1, 阅读全文
posted @ 2021-06-07 09:57 小鲨鱼2018 阅读(989) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; int lines = 0; double c1, c2, c3; double c1sum = 0, c2sum = 0, c3sum = 0; if((fp = fopen("a.txt","r") 阅读全文
posted @ 2021-06-06 22:34 小鲨鱼2018 阅读(654) 评论(0) 推荐(0)
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; //打开文件前必须要定义FILE*型指针变量 int lines = 0; char name[128]; double height, weight; double hsum = 0, wsum = 阅读全文
posted @ 2021-06-06 22:17 小鲨鱼2018 阅读(351) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 30 下一页