小明种苹果续
题目可去ccf认证管理系统查看,这里直接给出代码
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int N,T,D = 0,E = 0;
cin>>N;
int b[N] = {0};
int **a = new int *[N];
for(int i = 0; i < N; i++){
int num,sum = 0,flag = 0;
cin>>num;
a[i] = new int [num+1];
a[i][0] = num;
for(int j = 1; j < num + 1; j++){
cin>>a[i][j];
if(a[i][j] > 0 && j != 1){
if(sum != a[i][j]){
flag = 1;
}
sum = a[i][j];
}else
sum += a[i][j];
}
T += sum;
if(flag){
D ++;
b[i] = 1;
}
}
if(b[N-2]+b[N-1]+b[0] == 3)
E++;
if(b[N-1]+b[0]+b[1] == 3)
E++;
for(int i = 0; i < N-2; i++){
if(b[i]+b[i+1]+b[i+2] == 3)
E++;
}
cout<<T<<ends<<D<<ends<<E;
return 0;
}