摘要: 3.文件 示例代码运行结果如下: 生成的file3.txt内容如下: 输出与生成文件的内容均完整可读。 4.二进制文件 (1)示例代码运行结果如下: 生成的file4.txt内容如下: 输出内容完整可读,而生成的文件显示为乱码,这是因为file4是用二进制方式写入的。 (2)代码如下: 1 #inc 阅读全文
posted @ 2021-06-12 10:17 namelessbird 阅读(50) 评论(1) 推荐(0) 编辑
摘要: 1.学生信息处理 代码如下: (全部手敲了一遍累到自己了,就没有加很多注释.....) 1 #include <stdio.h> 2 #include <string.h> 3 #define N 3 4 typedef struct student{ 5 int num; //学号 6 char 阅读全文
posted @ 2021-06-04 22:01 namelessbird 阅读(62) 评论(1) 推荐(0) 编辑
摘要: 1.一维数组 代码如下: 1 #include <stdio.h> 2 const int N=3; 3 int main() { 4 int a[N] = {1, 2, 3}; 5 int i; 6 printf("通过数组名和下标直接访问数组元素:\n"); 7 for(i=0; i<N; i+ 阅读全文
posted @ 2021-05-21 23:20 namelessbird 阅读(80) 评论(1) 推荐(0) 编辑
摘要: 1.递归函数 代码如下: 1 #include <stdio.h> 2 long long fun(int n); 3 int main() { 4 int n; 5 long long f; 6 while(scanf("%d",&n)!=EOF){ 7 f=fun(n); 8 printf("n 阅读全文
posted @ 2021-04-28 22:36 namelessbird 阅读(51) 评论(2) 推荐(0) 编辑
摘要: 1.随机数生成 代码如下: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 #define N 5 5 int main() { 6 int x,n; 7 srand(time(0)); 8 for (n = 1; n 阅读全文
posted @ 2021-04-10 18:17 namelessbird 阅读(121) 评论(2) 推荐(0) 编辑
摘要: 1.格式化输入输出 源代码如下: 1 #include <stdio.h> 2 int main() { 3 int num; 4 scanf("%d", &num); 5 printf("2049%04d\n", num); 6 scanf("%d", &num); 7 printf("2049% 阅读全文
posted @ 2021-03-28 23:02 namelessbird 阅读(42) 评论(3) 推荐(0) 编辑
摘要: 实验任务1:在横向方向上打印出两个字符小人 1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() { 4 printf(" O O \n"); 5 printf("<H> <H> \n"); 6 printf("I I I I \n"); 7 阅读全文
posted @ 2021-03-13 16:06 namelessbird 阅读(73) 评论(0) 推荐(0) 编辑