#include<stdio.h>
int main()
{
int i=0;
double sum=0.0;
int zhuan=1;
for(i=1;i<=100;i++)
{
sum+=zhuan*1.0/i;
zhuan=-zhuan;
}
......................
阅读全部
|
Dnoe
贴于 2021年2月27日 18:17
hide
bbsi
#include<stdio.h>
#include<math.h>
int main() {
int i=0;
int count=0;
for(i=101; i<=200; i+=2)
{
int j=0;
for(j=2;j<sqrt(i);j++)
{
if(i%j==0)
......................
阅读全部
|
Dnoe
贴于 2021年2月27日 17:37
hide
bbsi
/*
01背包动态规划思维不同于常规思维,
掌握方法及参数的内容,
动态转移方程的理解熟。
通过实例学习,
序号(i)|单个物体重量w(i)|单个物品价值v(i)
1 22 15
2 18 18
3 9 10
4 24 13
5 15 20
包能承最大重35
......................
阅读全部
|
qunxingw
贴于 2021年2月18日 11:54
hide
bbsi
def twonums(nums,target):
hashmap=dict()
for i in range(len(nums)):
if hashmap.get(target-nums[i]) is None:
hashmap[nums[i]]=i
else:
return [hashmap.get(target-nums[i]),i]
if __name__=='__main__':
nums=[4,3,7,9]
n=twonums(nums,11)
......................
阅读全部
|
qunxingw
贴于 2021年2月15日 09:44
hide
bbsi
#include <stdio.h>
#include <malloc.h>
#include <ctype.h>
#include <string.h>
bool file_exists(const char* file)
{
FILE* f = fopen(file, "r");
if (!f) {
return false;
}
......................
阅读全部
|
lvhui123456
贴于 2021年1月27日 15:57
hide
bbsi
#include <stdio.h>
#include <malloc.h>
#include <ctype.h>
#include <string.h>
bool file_exists(const char* file)
{
FILE* f = fopen(file, "r");
if (!f) {
return false;
}
......................
阅读全部
|
lvhui123456
贴于 2021年1月27日 15:56
hide
bbsi
// https://v.douyin.com/JTdQ2So/ 矗接觀看视频!
#include<stdio.h>
int A[9];
int a[9]={1,2,3,4,5,6,7,8,9};
int isok(int n)//分析A[]第N个数与前面的数比较为递归 作准备。
{
int flag=1,i;
for(i=0;i<n;i++){
if(A[n]==A[i]) flag=0;//不与前面已选择的数相同
......................
阅读全部
|
qunxingw
贴于 2021年1月26日 17:01
hide
bbsi
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
void waiting(),stop();
int wait_mark;
void main() {
int p1,p2;
if (p1=fork()) { /*创建子进程 p1*/
if (p2=fork()) { /*创建子进程 p2*/
......................
阅读全部
|
blue1
贴于 2021年1月25日 19:51
hide
bbsi
#Python代码以实例展示求解方程的根。
import math
def f(x):
return math.pow(x,3)-9*x+1
def fd(x):
return 3*math.pow(x,2)-9
def newton_method(n,x):
times = n
next_x = 0
y= f(x)
yd = fd(x)
......................
阅读全部
|
qunxingw
贴于 2021年1月19日 09:56
hide
bbsi