Discuz! Board

 找回密码
 立即注册
查看: 509|回复: 0

23.3.4搜索,贪心

[复制链接]

15

主题

19

帖子

4118

积分

论坛元老

Rank: 8Rank: 8

积分
4118

墨海马 Lv:15
发表于 2023-3-4 18:10:21 | 显示全部楼层 |阅读模式
[C] 纯文本查看 复制代码
void test1()//格式化输入 
{
	int a,b;
	scanf("%d/%d",&a,&b);
	cout<<a<<b;
}
void search7(int n)
{
	for(int i=0;i<5;i++)
	{
		if(b[i]==0)
		{
			a1[n]=i;
			b[i]=1;
			s+=shouyi[n][i];
			if(n==4&&max1<=s)
			{
				max1=s;
				memmove(a,a1,sizeof(a1));
			}
			else
			{
				search7(n+1);
			}
			b[i]=0;
			s-=shouyi[n][i];
		}
	}
}
void gzfp()//工作分配
{
	search7(0);
	for(int i=0;i<5;i++)
	{
		cout<<shouyi[i][a[i]]<<' ';
	}
} 
#include<bits/stdc++.h>
using namespace std;
#include<time.h> //包含随机数,时间函数 
int dashui()//单水龙头打水 
{
	int s=0,s1=0;
	srand(time(0));//随机种子函数  
	int a[2];
	for(int i=0;i<2;i++)
	{
		a[i]=rand()%10;
		cout<<a[i]<<' ';
	}
	cout<<endl;
	sort(a,a+2);
	for(int i=0;i<2;i++)
	{
		s+=a[i];
		s1+=s;
	}
	cout<<s1;
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2025-5-30 12:11 , Processed in 0.060246 second(s), 27 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.. 技术支持 by 巅峰设计

快速回复 返回顶部 返回列表