2019年第十届蓝桥杯C/C++ 省赛B组真题第一题组队

多次验证目前CSDN上发的DFS的基本都是错误的代码,跑不出正确结果。于是写了一个最傻的遍历代码。
在这里插入图片描述
在这里插入图片描述

#include<stdio.h>
#include<stdlib.h>
#define max(a,b) ((a) > (b) ? (a) : (b))
int Score[20][5]={	97,90,0,0,0,
					92,85,96,0,0,
					0,0,0,0,93,
					0,0,0,80,86,
					89,83,97,0,0,
					82,86,0,0,0,
					0,0,0,87,90,
					0,97,96,0,0,
					0,0,89,0,0,
					95,99,0,0,0,
					0,0,96,97,0,
					0,0,0,93,98,
					94,91,0,0,0,
					0,83,87,0,0,
					0,0,98,97,98,
					0,0,0,93,86,
					98,83,99,98,81,
					93,87,92,96,98,
					0,0,0,89,92,
					0,99,96,95,81
					};

int used[20];
int sum = 0;
int sum_max = 0;
int a,b,c,d,e = 0;

int main()
{
	for(a=0;a<20;a++)
	{
		sum+=Score[a][0];
		for(b=0;b<20;b++)
		{
			if(a!=b)
			{
				sum+=Score[b][1];
				for(c=0;c<20;c++)
				{
					if(a!=c&&b!=c)
					{
						sum+=Score[c][2];
						for(d=0;d<20;d++)
						{
							if(d!=c&&d!=b&&d!=a)
							{
								sum+=Score[d][3];
								for(e=0;e<20;e++)
								{
									if(e!=d&&e!=c&&e!=b&&e!=a)
									{
										sum+=Score[e][4];
										sum_max = max(sum_max,sum);
										sum-=Score[e][4];
									}
								}
								sum-=Score[d][3];
							}
						}
						sum-=Score[c][2];
					}
				}
				sum-=Score[b][1];
			}
		}
		sum-=Score[a][0];
	}
	printf("%d",sum_max);
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值