标签:ber while pac 判断 mes include namespace res names
1 #include<iostream> 2 #include<cstring> 3 #include<stdio.h> 4 using namespace std; 5 double res[1001]; 6 int main () { 7 int K, n,loop=2,number = 0; 8 double a; 9 while(loop --) { 10 cin >> K; 11 for(int i = 0; i < K; i++) { 12 cin >> n >> a; 13 if(res[n] == 0) number++; 14 res[n] += a; 15 if(res[n] == 0) number--; 16 } 17 } 18 if(number == 0) {cout << number; return 0;} //注意!末尾不要留空格 19 cout << number << " "; 20 for(int i = 1000; i >= 0; i--) { 21 if(res[i] != 0) { 22 printf("%d %.1f",i,res[i]); 23 number --; 24 if(number != 0) { 25 printf(" "); 26 } 27 } 28 } 29 }
这题犯了 之前一直再犯的错误,就是 各种临界条件的判断,总是会漏想一些情况。
标签:ber while pac 判断 mes include namespace res names
原文地址:https://www.cnblogs.com/dcklm/p/10339412.html