1. 程式人生 > 其它 >問題 G: 數字分類 (20)

問題 G: 數字分類 (20)

技術標籤:Codeup新家

注意:
判斷A[2]的時候一定要通過個數來判斷否則91分如圖

#include<cstdio>
#include<cmath>
void count(int number, int *a);

int main(){
	int i = 0;
	int nums = 0;
	int number = 0;
	int A[7] = {0};
	double temp = 0;
	while(scanf("%d", &nums) != EOF){
		for(i = 0; i < nums; i++){
			scanf
("%d", &number); count(number, A); } temp = A[4] / (A[6] * 1.0); //A[1] if(A[1] != 0){ printf("%d ", A[1]); }else{ printf("N "); } //A[2] if(A[0] != 0){ printf("%d ", A[2]); }else{ printf("N "); } //A[3] if(A[3] != 0){ printf
("%d ", A[3]); }else{ printf("N "); } //A[4] if(A[6] != 0){ printf("%.1f ", temp); }else{ printf("N "); } //A[5] if(A[5] != 0){ printf("%d", A[5]); }else{ printf("N"); } //清零 for(i = 0; i < 7; i++){ A[i]
= 0; } } return 0; } void count(int number, int *a){ if(number % 10 == 0){ a[1] += number; }else if(number % 5 == 1){ a[0]++; a[2] = a[2] + pow(-1, a[0]-1) * number; }else if(number % 5 == 2){ a[3]++; }else if(number % 5 == 3){ a[6]++; a[4] = a[4] + number; }else if(number % 5 == 4){ if(number > a[5]){ a[5] = number; } } }

在這裡插入圖片描述