#include<iostream> #include<vector> #include<string> #include<cstdio> using namespace std; int main() { int n; int count = 1; while (cin >> n) { getchar(); if (n == 0) break; else { cout << "Case #" << count++ << ":" << endl; //printf("Case #%d:\n", count++); while (n--) { int num[3] = { 0 }; int zs[3] = { 0 }; string s; getline(cin, s); //s.replace() for (int i = 0;i < s.size();i++) { if (s[i] == 'X') { zs[0] = s[i + 2] - '0'; num[0] += s[i - 2] - '0'; } else if (s[i] == 'Y') { zs[1] = s[i + 2] - '0'; num[1] += s[i - 2] - '0'; } else if (s[i] == 'Z') { zs[2] = s[i + 2] - '0'; num[2] += s[i - 2] - '0'; } } if (num[0] != 0) { if (zs[0] != 0) { cout << zs[0] * num[0] << " * X ^ " << zs[0] - 1; //printf("%d * X ^ %d", zs[0] * num[0], zs[0] - 1); } else { cout << num[0]; } } if (num[1] != 0) { if(num[0]!=0) cout << " + "; if (zs[1] != 0) { cout << zs[1] * num[1] << " * Y ^ " << zs[1] - 1; //printf("%d * Y ^ %d", zs[1] * num[1], zs[1] - 1); } else { cout << num[1]; } } if (num[2] != 0) { cout << " + "; if (zs[2] != 0) { cout << zs[2] * num[2] << " * Z ^ " << zs[2] - 1; //printf("%d * Z ^ %d", zs[2] * num[2], zs[2] - 1); } else { cout << num[2]; } } cout << endl; } } } } /* Main.c:1:9: fatal error: iostream: No such file or directory #include<iostream> ^~~~~~~~~~ compilation terminated. */ |
Double click to view unformatted code.