题解列表

筛选

题解:装箱问题【Python求解】

摘要:解题思路:递归参考代码:## 递归算法 V = int(input())     n = int(input()) v_lis = [] for i in range(n):     v =……

题解: 公交汽车【Python】

摘要:解题思路:动态规划。参考代码:cost = list(map(int, input().split())) n = int(input()) dp = [0 for i in range(n)] ……

题解: 数字三角形【Python】

摘要:解题思路:动态规划参考代码:N = int(input()) dp = [] for i in range(N):     row = list(map(int, input().split()……

最大数位置

摘要:解题思路:先用数组存储数据,然后将第一个值定为最大值,利用循环遍历数组和最大值比较如果大于最大值,将这个值赋值为最大值。注意事项:输出的i要加一参考代码:#include<stdio.h>#inclu……

冒泡排序法C语言

摘要:解题思路:冒泡排序法注意事项:注意i和j的使用。参考代码:#include<stdio.h>#include<stdlib.h>int main(){    int n,num[100];    in……

这个方法还不错!

摘要:解题思路:对于本体解法,这里将运用结构体struct将10个数从大到小依次排列注意事项:malloc参考代码:#include<stdio.h> #include<malloc.h> #defin……

递归法求最大公约数

最大公约数,采用辗转相除法,即对于ay){c=x%y;if(c)returnyue(y,c);elsereturny;}elsereturnx;}intbei(intx,inty)//最小公倍数(两数之积等于最大公因数与最小公倍数的乘积){returnx*y/yue(x,

C语言 自定义函数&

摘要:解题思路:注意事项:参考代码:#include <stdio.h>#include <math.h>#define LONG 10int main(){         double fact(int……

自定义函数处理素数(简单易懂)

解题思路:定义一函数判断参数(x)是否为素数,是素数则返回0,否则返回1判断方法:若x能整除2到x-1中的任意一个数则x不是素数(当x=2不做判断)构建循环遍历2到x-1的数(循环变量为i)让x除以i若x%i==0即能整除能整除令t=1;不能整除则t=0;只要有一次能整除(t=1)就证明x不是素数,

救援(数学解题法)

摘要:解题思路:注意事项:注意有多个屋顶,时间需要累加参考代码:#include<stdio.h>#include<math.h>int main(){ int n,x,y,s; float l,t=0; ……