摘要: 问题描述: 问题分析: 题目理解:首先****PAT****正确,左侧*和右侧*一样多,且如果有*,只能是A其次 如果每次往P和T中间加一个A,则T后面增加P前面的*数量,通过递推可知:T后面的*数量是P前面的P和T之间的A的个数倍 代码展示: 1 //题目理解:首先****PAT****正确,左侧 阅读全文
posted @ 2020-03-27 23:14 kakusan 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 之前写了一下C语言操作文件的代码,将打要读写的文件名直接用字符串常量的方式写在代码里面,只要运行目录下存在需要文件,调试和双击打开都没问题,唯独Win命令行运行是出现问题。 于是尝试将需要打开和写入的文件名在命令行以字符串方式输入,然后用main函数的char * argv[]传参,问题得到有效解决 阅读全文
posted @ 2020-03-27 18:06 kakusan 阅读(849) 评论(0) 推荐(0) 编辑
摘要: 样例输入:123 样例输出:321 代码如下: 1 //将一个整数翻转输出 2 #include <stdio.h> 3 int main() 4 { 5 int a; 6 int j,m=0; 7 scanf("%d",&a); 8 while((j=a/10)!=0) 9 { 10 m=m*10 阅读全文
posted @ 2020-03-26 12:26 kakusan 阅读(511) 评论(0) 推荐(0) 编辑
摘要: 1 //顺序文件读写,文件路径问当前工作空间 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 char fname[10]; 6 FILE *fp; 7 char *p=fname; 8 char ch; 9 int main() 10 { 11 print 阅读全文
posted @ 2020-03-22 17:18 kakusan 阅读(471) 评论(0) 推荐(0) 编辑
摘要: 1 //链表操作,涉及到链表首节点指针变动的函数,即使形参包含首节点指针,必须返回首节点指针,原因不得而知 2 # include<stdio.h> 3 # include<stdlib.h> 4 struct Student 5 { 6 int num; 7 struct Student* nex 阅读全文
posted @ 2020-03-20 12:18 kakusan 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 1 //create 函数用传指针方式没法创建链表? 2 3 #include<stdio.h> 4 #include<stdlib.h> 5 struct Person 6 { 7 int num; 8 struct Person *next; 9 }; 10 11 int main() 12 { 阅读全文
posted @ 2020-03-19 15:00 kakusan 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 代码展示: //结构体指针实现动态链表 #include<stdio.h> #include<stdlib.h> # define LEN sizeof(struct Student) struct Student{ int num; char name[20]; float score; stru 阅读全文
posted @ 2020-03-17 23:06 kakusan 阅读(537) 评论(0) 推荐(0) 编辑
摘要: 代码如下: 1 // 求一个字符串里面出现的连续数字个数,并将连续数字的整形存储在一个整形数组里面,然后输出 2 # include<stdio.h> 3 int a[20]={0}; 4 char c[50]; 5 int main() 6 { 7 printf("请输入字符串:"); 8 get 阅读全文
posted @ 2020-03-16 23:52 kakusan 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 矩形法求积分就是按照积分的定义将被积函数的积分区域分成很多个小矩形,然后累加求和的过程 代码如下: 1 // 矩形法求sinx cosx exp(x) 的积分 2 # include<stdio.h> 3 # include<math.h> 4 double a,b,c; 5 int n=20,d; 阅读全文
posted @ 2020-03-16 23:11 kakusan 阅读(578) 评论(0) 推荐(0) 编辑
摘要: 问题描述:有n个人排成一圈,循环报数,毎到数字k,那人自动退出,下个人继续从1开始报数,如此循环,直至剩下最后一个人。问最后那个人的序号是多少? 代码如下: 1 //约瑟夫环问题,以n为总人数,k(此处为3)为循环退出的序号 2 #include<stdio.h> 3 int c[100]; 4 i 阅读全文
posted @ 2020-03-16 16:33 kakusan 阅读(151) 评论(0) 推荐(0) 编辑