摘要: 问题: 算法设计: 第j次卖出余下的(j+1)分之一加1/(j+1),第四次买完后剩下11条 假设第j次前还剩下x条所以x+1必定处尽j+1 x从23开始取,一直加2 代码: #include<stdio.h> int main() { int i,j,x,flag=0; for(i=23;flag 阅读全文
posted @ 2023-05-04 19:34 皮卡丘和杰尼龟 阅读(19) 评论(0) 推荐(0)
摘要: 问题: 算法设计: 根据问题可以计算出每个颜色球的取值范围 红球为M<3,白球为N<3,黑球为8-M-N<6 流程图: 源代码: #include<stdio.h>int main(){ int m,n,number=0; for(m=0;m<=3;m++) for(n=0;n<=3;n++) if 阅读全文
posted @ 2023-04-27 22:43 皮卡丘和杰尼龟 阅读(24) 评论(0) 推荐(0)
摘要: 问题: 算法设计: 定义一个数组存放每个小孩的初始糖果数量,因为只要每个人糖果的数量不同就要继续执行,用循环写出其中的过程,知道糖果一样多; 流程图: 程序源代码: #include<stdio.h> void print(int s[]); int judge(int c[]); int j=0; 阅读全文
posted @ 2023-04-26 20:02 皮卡丘和杰尼龟 阅读(22) 评论(0) 推荐(0)
摘要: 问题: 算法设计; 直接根据题意写出代码。 源代码: #include<stdio.h>#include<math.h>int main(){ int x1,x2,x3,x5,x8,y1,y2,y3,y5,y8; double max=0.0,result; for(x8=0;x8<=2;x8++) 阅读全文
posted @ 2023-04-25 20:45 皮卡丘和杰尼龟 阅读(19) 评论(0) 推荐(0)
摘要: 问题: 算法设计: 直接根据题意暴力写出 源代码: #include<stdio.h>int main(){ int a; double b=0.0; if(a<=3500) printf("不征收"); else { if(a>=3500&&a<=4500) { b=1500*0.03+(a-15 阅读全文
posted @ 2023-04-24 20:14 皮卡丘和杰尼龟 阅读(18) 评论(0) 推荐(0)
摘要: 问题: 给定一个N进制的数,将他转换为M进制的数。 设计方案: 所有的数都是由0~F组成,因此采用字符数组进行存储。同时定义两个函数进行字符和数值之间的转换。 源代码: #include<stdio.h>#define MAXCHAR 101int char_to_num(char ch);char 阅读全文
posted @ 2023-04-22 21:40 皮卡丘和杰尼龟 阅读(20) 评论(0) 推荐(0)
摘要: 问题: N个有序整数数列已放在一维数组中,利用二分查找法查找整数m在数组中的位置若找到,则输出其下标值;反之,则输出“Notbefound” 设计: 利用二分查找,寻找此数。 流程图 源代码: #include<stdio.h>#define N 10int main(){ int i,a[N]={ 阅读全文
posted @ 2023-04-20 20:36 皮卡丘和杰尼龟 阅读(22) 评论(0) 推荐(0)
摘要: 问题: 输入N个数升序排序 设计: n个数比较n-1次每一次把最大的排在最前面 源代码: #include<stdio.h> int main() { int i,j,a[N],t; for(i=0;i<N;i++) scanf("%d",&a[i]); for(i=1;i<=N-1;i++) fo 阅读全文
posted @ 2023-04-19 20:36 皮卡丘和杰尼龟 阅读(20) 评论(0) 推荐(0)
摘要: 问题: 假设银行一年整存零取的月息为0.63%。现在某人手中有一笔钱,他打算在今后的5年中的每年年底取出1000元,到第5年时刚好取完,请算出他存钱时应存入多少。 设计: 从第五年往前推可以算出。因此可以使用for循环语句,循环4次,每次循环都在上一次的基础上加上1000,再除以(1+12x0.00 阅读全文
posted @ 2023-04-18 11:43 皮卡丘和杰尼龟 阅读(21) 评论(0) 推荐(0)
摘要: 牛顿迭代求根: #include<stdio.h>#include<math.h>int main(){ float solution(float a,float b,float c,float d); float a,b,c,d,x; scanf("%f %f %f %f",&a,&b,&c,&d 阅读全文
posted @ 2023-04-17 20:07 皮卡丘和杰尼龟 阅读(24) 评论(0) 推荐(0)