2020-09 CCF-CSP 风险人群筛查 C和C++混写

2020-09 CCF-CSP 风险人群筛查 C和C++混写

前言
本次学习所用设备为微软Surface pro4,操作系统为windows10

注意事项
(1)CFF-CSP考试提交一定要使用C++编译环境 。

题目

实现代码如下

#include<iostream>
#include<algorithm>
using namespace std;
int x[1005] = {0};
int y[1005] = {0};
int main()
{
	int n,i,j;     //进行计数
	//输入第一行所需要的值 
	int k,t,xl,yd,xr,yu; 
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%d",&t);
	scanf("%d",&xl);
	scanf("%d",&yd);
	scanf("%d",&xr);
	scanf("%d",&yu);
	int result_first = 0;
	int result_second = 0;
	for(i = 1;i <= n;i++)
	{
		int count_first = 0;
		int number = 1;
		int count_flag[1005] = {0};
		int count_second[1005] = {0};
		for(j = 1;j <= t;j++)
		{
			scanf("%d",&x[j]);
			scanf("%d",&y[j]);
		}
		
		for(j = 1;j <= t;j++)
		{
			//属于区域 
			if((x[j] >= xl) && (x[j] <= xr) && (y[j] >= yd) && (y[j] <= yu)) 
		    {
			    count_first++;
			    count_flag[j]++;
		    }
		    //属于区域并且连续 
		    if((x[j] >= xl) && (x[j] <= xr) && (y[j] >= yd) && (y[j] <= yu) && (count_flag[j-1] == 1))
		    {
			    count_second[number]++;
			    if((count_second[number] + 1) >= k)
			    {
				    result_second++;
			    	break;
				}
		    }
		    else{
		    	number++;
			}
		   // printf("k=%d x[j]=%d y[j]=%d count_flag[%d]=%d count_first=%d count_second[number]=%d result_first=%d result_second=%d\n",k,x[j],y[j],j,count_flag[j],count_first,count_second[number],result_first,result_second); 			
		}
		
		if(count_first != 0)
		{
			result_first++;
		}
	}
	printf("%d\n",result_first);
	printf("%d",result_second);
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值