【1002】 A+B for Polynomials (25 分)
1 //1002 A+B for Polynomials (25 分) 2 #include<iostream> 3 #include<iomanip> 4 using namespace std; 5 double a[1001] = { 0 }; 6 int main() { 7 int k,n,count=0; 8 double x; 9 int group = 2; 10 while (group--) { 11 cin >> k; 12 for (int i = 0; i < k; i++) { 13 cin >> n >> x; 14 a[n] += x; 15 } 16 } 17 for (int i = 0; i < 1001; i++) { 18 if(a[i]!=0) 19 count++; 20 } 21 cout << count; 22 for (int i = 1000; i >= 0; i--) { 23 if (a[i] != 0) 24 cout << " " << i << " "<< setiosflags(ios::fixed) << setprecision(1) << a[i]; 25 } 26 return 0; 27 28 }