Title Description
Given some of the positive integer column, please be classified according to the requirements of digital, and digital outputs the following five categories:
- A1 = divisible numbers can be 5 and all even
- A2 = 5 can be more than 1 after the digital addition is performed in the order given staggered sum, i.e. calculate n1 - n4 ... - n2 + n3
- A3 = 2 is the number of the digital I except 5
- A4 = 5 is the average addition to more than 3 after the numbers to the nearest decimal place
- A5 = 4 is the maximum number than the number 5 in addition to
Input Format
Each input comprises a test, each test is given to a positive integer not more than 1000 N, and then gives the N does not exceed 1000 to be classified positive integer. Separated by spaces between numbers
Output Format
For a given positive integer N, is calculated according to A1 ~ A5 subject of the request and sequentially outputting in a row. Between numbers separated by spaces, but the end of the line may not have extra spaces
If a certain type wherein the number does not exist, the corresponding output position "N"
Sample input 1
13 1 2 3 4 5 6 7 8 9 10 20 16 18
Sample Output 1
30 11 2 9.7 9
Sample input 2
8 1 2 4 5 6 7 9 15
Sample Output 2
N 11 2 N 9
int main(int argc, char *argv[]) { int res[5] = {0, 0, 0, 0, 0}; int count[5] = {0, 0, 0, 0, 0}; int n, temp; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%d", &temp); if(temp % 5 == 0){ if(temp % 2 == 0){ years [ 0 ] + Temp; count[0]++; } }else if(temp % 5 == 1){ if(count[1] % 2 == 0){ res[1] += temp; }else{ res[1] -= temp; } }else if(temp % 5 == 2){ res[2]++; }else if(temp % 5 == 3){ res[3] += temp; count[3]++; }else if(temp % 5 == 4){ if(count[4] < temp){ count[4] = temp; } count[4]++; } } if(count[0] == 0){ printf("N "); }else{ printf("%d ", res[0]); } if(count[1] == 0){ printf("N "); }else{ printf("%d ", res[1]); } if(count[2] == 0){ printf("N "); }else{ printf("%d ", res[2]); } if(count[3] == 0){ printf("N "); }else{ printf("%.1f ", (double)res[3]/count[3]); } if(count[4] == 0){ printf("N"); }else{ printf("%d", res[4]); } return 0; }
The key problem solution
- Filled pit format, one decimal place, .1f