#include <iostream> #include <string> using namespace std; int n = 0; int n2 = 0; string outCommand; int main() { cin >> n; n2 = n; int tempN0 = n2; while (tempN0 > 9) { outCommand.append(to_string(9)); outCommand.append("A"); tempN0 -= 9; } if (tempN0 != 1) outCommand.append(to_string(tempN0)); outCommand.append("A"); int tempN2 = n2; while (tempN2 > 9) { outCommand.append(to_string(9)); outCommand.append("E"); tempN2 -= 9; } if(tempN2 != 1) outCommand.append(to_string(tempN2)); outCommand.append("E"); int i = 0; while (i < n - 1) { n2--; int tempN = n2; while (tempN > 9) { outCommand.append(to_string(9)); outCommand.append("[CA]"); tempN -= 9; } if (tempN != 1) { outCommand.append(to_string(tempN)); outCommand.append("[CA]"); } else outCommand.append("CA"); outCommand.append("C"); int tempN1 = n2; while (tempN1 > 9) { outCommand.append(to_string(9)); outCommand.append("E"); tempN1 -= 9; } if (tempN1 != 1) outCommand.append(to_string(tempN1)); outCommand.append("E"); i++; } outCommand.append("C"); cout << outCommand << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <iostream> #include <string> using namespace std; int n = 0; int n2 = 0; string outCommand; int main() { cin >> n; n2 = n; int tempN0 = n2; while (tempN0 > 9) { outCommand.append(to_string(9)); outCommand.append("A"); tempN0 -= 9; } if (tempN0 != 1) outCommand.append(to_string(tempN0)); outCommand.append("A"); int tempN2 = n2; while (tempN2 > 9) { outCommand.append(to_string(9)); outCommand.append("E"); tempN2 -= 9; } if(tempN2 != 1) outCommand.append(to_string(tempN2)); outCommand.append("E"); int i = 0; while (i < n - 1) { n2--; int tempN = n2; while (tempN > 9) { outCommand.append(to_string(9)); outCommand.append("[CA]"); tempN -= 9; } if (tempN != 1) { outCommand.append(to_string(tempN)); outCommand.append("[CA]"); } else outCommand.append("CA"); outCommand.append("C"); int tempN1 = n2; while (tempN1 > 9) { outCommand.append(to_string(9)); outCommand.append("E"); tempN1 -= 9; } if (tempN1 != 1) outCommand.append(to_string(tempN1)); outCommand.append("E"); i++; } outCommand.append("C"); cout << outCommand << endl; } |