前言
本次学习所用设备为微软Surface pro4,操作系统为windows10。
注意事项
(1)CFF-CSP考试提交一定要使用C++编译环境 。
题目
实现代码如下
#include#include 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=%dn",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("%dn",result_first); printf("%d",result_second); return 0; }



