From 4ea01eb47709e91982435fa4e10512e3a5626012 Mon Sep 17 00:00:00 2001 From: cnhacklqr Date: Tue, 23 Jan 2024 19:03:41 +0800 Subject: [PATCH] Update Code --- src/algorithm/digui/addNumber.cpp | 19 ++++++ src/algorithm/digui/commonFactor.cpp | 16 +++++ src/algorithm/digui/daoxuchuzhuNumbers.cpp | 27 ++++++++ src/algorithm/digui/fib.cpp | 17 +++++ src/algorithm/digui/jinzhizhuanhuan.cpp | 64 ++++++++++++++++++ src/algorithm/digui/nixushuchuzifu.cpp | 18 +++++ src/algorithm/digui/sbshangliuti copy.cpp | 26 +++++++ src/algorithm/digui/sbshangliuti.cpp | 25 +++++++ src/algorithm/ditui/shuzisanjiaoxing.cpp | 36 ++++++++++ .../fenzhi/findLastXiaoyvDengyvNumber | Bin 0 -> 16168 bytes .../fenzhi/findLastXiaoyvDengyvNumber.cpp | 40 +++++++++++ .../fenzhi/mianxiangjieguobiancheng.cpp | 17 +++++ src/algorithm/findNumber | Bin 0 -> 16224 bytes src/algorithm/findNumber.cpp | 31 +++++++++ src/algorithm/hanoi | Bin 0 -> 15936 bytes src/algorithm/hanoi.cpp | 21 ++++++ src/luckyNumber.cpp | 37 ++++++++++ src/type/stringTo | Bin 0 -> 17584 bytes src/type/stringTo.cpp | 25 +++++++ 19 files changed, 419 insertions(+) create mode 100644 src/algorithm/digui/addNumber.cpp create mode 100644 src/algorithm/digui/commonFactor.cpp create mode 100644 src/algorithm/digui/daoxuchuzhuNumbers.cpp create mode 100644 src/algorithm/digui/fib.cpp create mode 100644 src/algorithm/digui/jinzhizhuanhuan.cpp create mode 100644 src/algorithm/digui/nixushuchuzifu.cpp create mode 100644 src/algorithm/digui/sbshangliuti copy.cpp create mode 100644 src/algorithm/digui/sbshangliuti.cpp create mode 100644 src/algorithm/ditui/shuzisanjiaoxing.cpp create mode 100755 src/algorithm/fenzhi/findLastXiaoyvDengyvNumber create mode 100644 src/algorithm/fenzhi/findLastXiaoyvDengyvNumber.cpp create mode 100644 src/algorithm/fenzhi/mianxiangjieguobiancheng.cpp create mode 100755 src/algorithm/findNumber create mode 100644 src/algorithm/findNumber.cpp create mode 100755 src/algorithm/hanoi create mode 100644 src/algorithm/hanoi.cpp create mode 100644 src/luckyNumber.cpp create mode 100755 src/type/stringTo create mode 100644 src/type/stringTo.cpp diff --git a/src/algorithm/digui/addNumber.cpp b/src/algorithm/digui/addNumber.cpp new file mode 100644 index 0000000..6db2fef --- /dev/null +++ b/src/algorithm/digui/addNumber.cpp @@ -0,0 +1,19 @@ +#include + +int sum = 0; + +void add(int n) { + if (n == 0) { + return; + } + sum += n; + add(n - 1); +} + +int main() { + int n; + std::cin >> n; + add(n); + std::cout << sum << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/commonFactor.cpp b/src/algorithm/digui/commonFactor.cpp new file mode 100644 index 0000000..a5a23c8 --- /dev/null +++ b/src/algorithm/digui/commonFactor.cpp @@ -0,0 +1,16 @@ +#include +#include + +int commonFactor(int n, int m) { + if (std::max(n, m) % std::min(n, m) == 0) { + return std::min(n, m); + } + return commonFactor(std::min(n, m), std::max(n, m) % std::min(n, m)); +} + +int main() { + int n, m; + std::cin >> n >> m; + std::cout << commonFactor(n, m) << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/daoxuchuzhuNumbers.cpp b/src/algorithm/digui/daoxuchuzhuNumbers.cpp new file mode 100644 index 0000000..9a60060 --- /dev/null +++ b/src/algorithm/digui/daoxuchuzhuNumbers.cpp @@ -0,0 +1,27 @@ +#include + +int numberSize(int n) { + int numberSize; + while (n != 0) { + n /= 10; + numberSize++; + } + return numberSize; +} + +int daoxu(int n, int count) { + if (n == 0) { + return 0; + } + std::cout << n % 10; + daoxu(n / 10, count - 1); + return 0; +} + +int main() { + int n; + std::cin >> n; + daoxu(n, numberSize(n)); + std::cout << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/fib.cpp b/src/algorithm/digui/fib.cpp new file mode 100644 index 0000000..bd4a1b6 --- /dev/null +++ b/src/algorithm/digui/fib.cpp @@ -0,0 +1,17 @@ +#include + +int fibMap[100] = {0, 1, 1}; + +int fib(int n) { + if (fibMap[n] == 0) { + return fib(n - 1) + fib(n - 2); + } + return fibMap[n]; +} + +int main() { + int n; + std::cin >> n; + std::cout << fib(n) << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/jinzhizhuanhuan.cpp b/src/algorithm/digui/jinzhizhuanhuan.cpp new file mode 100644 index 0000000..38925e4 --- /dev/null +++ b/src/algorithm/digui/jinzhizhuanhuan.cpp @@ -0,0 +1,64 @@ +#include +#include + +class stack { +public: + stack(int size) { + this->data = new int[size]; // 分配内存 + this->topIndex = 0; + } + int pop() { + topIndex--; + return this->data[topIndex]; + } + void push(int value) { this->data[this->topIndex++] = value; } + int top() { return this->data[this->topIndex - 1]; } + bool empty() { return this->topIndex == 0; } + +private: + int *data; + int topIndex; +} number(100); + +int change(int n, int m) { + if (n == 0) { + return 0; + } + number.push(n % m); + return change(n / m, m); +} + +int main() { + int n, m; + std::cin >> n >> m; + change(n, m); + while (!number.empty()) { + if (number.top() > 9) { + switch (number.top()) { + case 10: + std::cout << 'A'; + break; + case 11: + std::cout << 'B'; + break; + case 12: + std::cout << 'C'; + break; + case 13: + std::cout << 'D'; + break; + case 14: + std::cout << 'E'; + break; + case 15: + std::cout << 'F'; + break; + } + } else { + std::cout << number.top(); + } + number.pop(); + } + std::cout << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/nixushuchuzifu.cpp b/src/algorithm/digui/nixushuchuzifu.cpp new file mode 100644 index 0000000..66e4c38 --- /dev/null +++ b/src/algorithm/digui/nixushuchuzifu.cpp @@ -0,0 +1,18 @@ +#include + +void daoxu(int n, std::string s) { + if (n == 0) { + return; + } + std::cout << s[n - 1]; + daoxu(n - 1, s); + return; +} + +int main() { + std::string s; + std::cin >> s; + daoxu(s.size() - 1, s); + std::cout << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/sbshangliuti copy.cpp b/src/algorithm/digui/sbshangliuti copy.cpp new file mode 100644 index 0000000..1f02265 --- /dev/null +++ b/src/algorithm/digui/sbshangliuti copy.cpp @@ -0,0 +1,26 @@ +#include +#include + +long long llist[10000] = {0, 1, 2, 4}; +long long count = 0; + +long long f(int x) { + if (llist[x] == 0) { + count++; + return f(x - 1) + f(x - 2) + f(x - 3); + } + count++; + return llist[x]; +} + +int main() { + long long x; + while (std::cin >> x) { + if (x == 0 || x == 114514) { + break; + } + std::cout << f(x) << std::endl; + std::cout << count << std::endl; + } + return 0; +} \ No newline at end of file diff --git a/src/algorithm/digui/sbshangliuti.cpp b/src/algorithm/digui/sbshangliuti.cpp new file mode 100644 index 0000000..f789f42 --- /dev/null +++ b/src/algorithm/digui/sbshangliuti.cpp @@ -0,0 +1,25 @@ +#include + +long long llist[10000] = {0, 1, 2, 4}; +long long count; + +long long f(int x) { + if (llist[x] == 0) { + llist[x] = f(x - 1) + f(x - 2) + f(x - 3); + count++; + return llist[x]; + } + return llist[x]; +} + +int main() { + long long x; + while (std::cin >> x) { + if (x == 0 || x == 114514) { + break; + } + std::cout << f(x) << std::endl; + std::cout << count << std::endl; + } + return 0; +} \ No newline at end of file diff --git a/src/algorithm/ditui/shuzisanjiaoxing.cpp b/src/algorithm/ditui/shuzisanjiaoxing.cpp new file mode 100644 index 0000000..589639d --- /dev/null +++ b/src/algorithm/ditui/shuzisanjiaoxing.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +struct temp { + int value = 0; + int index = 0; +}; + +int main() { + int n; + std::cin >> n; + + temp tmp[n]; + int listn[n][n], jtmp = 0, answer = 0; + memset(tmp, 0, sizeof(tmp)); + + for (int i = 0; i < n; i++) { + for (int j = 0; j <= i; j++) { + std::cin >> listn[i][j]; + } + } + + for (int i = n - 1; i >= 0; i++) { + for (int j = jtmp; j <= i; j++) { + tmp[j].value = std::max(listn[i + 1][j], listn[i + 1][j + 1]); + tmp[j].index = j; + std::sort(tmp, tmp + n, [](temp a, temp b) { return a.value > b.value; }); + jtmp = tmp[0].index; + } + answer += tmp[0].value; + } + + std::cout << answer << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/algorithm/fenzhi/findLastXiaoyvDengyvNumber b/src/algorithm/fenzhi/findLastXiaoyvDengyvNumber new file mode 100755 index 0000000000000000000000000000000000000000..e30fc2f2fef84279c960826753188b799ec7b9ae GIT binary patch literal 16168 zcmeHOeQX?85r5~8#A%z@X_MATLvu+#NJw+BeXi>^GChB+vqrJ&+A*X+yFTBY?QQKl zbGHt5m821-6~|$ziBK9uCECA;L?{u>AErpfX-b-)A~`BhOCXU#TFxYeeo;~ya{T7) zoAY^f7tw-*koH--GxK{h^JeGmuHW9yKB{eRE%JB-w_@>GLDEQtjRaK3;X4%r5)k!b zDfTysPl-j4OC)CZ2W)~~yUi9Yq-6>(1|_>nV)D>6HY}KOgha`%P&=#!U@FvckX2&0V~g?|k;(y{YXQRIOJVboR}x~4gCaIrc{8_V6l24Q_Jp!hF=UYiGR zEr7pS0RLVA{9*z8XaW4b0yyQzi_O_6A6_R2na-oSD_Ha3*di0ig$Bhm0sTd3Qrt_}?bmx?|mjCVOhC%~-;KZN$LY9S_FG4Kr$5yX+A|u~7?06&ec~ z{bn>cWIlq(Nin1jayUqiNeDe`ga#ir`h(_>fI`9whc<1ZYom_D;Vd^0f-OnagokW= z+xE7m=AAnYzpvKkuMs(-%^Nko+AQavXKQ?SUWzY9@zMu9kCoe)gt?t{5S15c#Kz3*EzbsGPW8-uUE7ua3&cSmp;!`Ux*2dY;AX(hfSUm~1OJ^2yjOnHKlF(UWqPXg^cErX$EK~K z%#1$qQrQVPK<18L0M6X{3ijn|1K>y=q`tYc8MIqpB$<{hb2CzYo@838%uP%A$0XB| zVD2bn8n61Tw&a-y_2eJ)iF0pv?$D~It555b4F_P9S?P!R`~AN1wO@w`0-9_{0?{W+ zzeeP)i`GhndOh(7bxG!I`PzM?cS2F<-!Jv==pwT5vYvcfKmM0{^y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0RNL57k3}W`SccWir<;f4+%%T_3kEnK+anU;>lN^y&5>pi#NbWWYbSee3jVOv=F~t z;m&dEfnU2&RZ8Ik_#?o*dGrqg&sQ)0g97@`7r=i7obqojw+E5Gg%OL|?C|zr!rEyD zW8=G8BGG~IT^*yteUZ2?G%_L!zpZ)$rRWx_v;9>DO1!PeKm;Y^F%)eF;|aq|7^BgI zIS`G6+aA)WG`yqxW0(woe3Nl9F>uo`G~HT0vCL-;0{_uo*Q*6Opi^LOmeM$5Ap))!}x5`X{cQw|&`_ z=@=%Qh#7-Hl;NWcK3k^0PzQ5?a(!owd^RQ&uX9yD*WoX;chu5n4Pi%x`EZTz2n?;G z1s@m;Vb1M&hEseXK;`-lZ(Rv)>GQmXnA2?k(OsQy3K4VC0`&}MGOmA`OM-yJM8 z$n%9nfv+HH>8v(Qv(ps9mlz+mf_-pRqPDx%N*fd!}AiRMctz1>hfGO~&!_I+f`LWv7;J*>x?u z4T7OHD%hmXDv;lQ^*jh0ON6E@sN>V5rEZ+_5OW0*=<4Y|raVraXTf zKkG5w3wv6_vdrsPrXy-3&N0W&0Zf9SoU(m@6w#RSI-194dp`arp-c8nWQ4}+a;Ci! zwZ8?SwY$^)8DNwX_Mcr(sC5NDuP8TiEar(mg)P_KtL&I|<|>0%-C6p5hdr;0n67i2 zaBRix{up=_%rb21vdunc@^_g|eU_R29=7E<_WT_BG-?&8v7Rl>%Z$_d zoz5K|pV$5Toh^S)%Xwrwp2zoLOZj7a{$6Wp3qZ6gn`HNF&-6p|@D&IR_~fUW0M19P10hV8O4>KDGoK$ItfzmsCGyFHuJi}IgiV_w2aPYzn}gwp + +int lastNumber = 0; + +void find(int l, int r, int x, int arr[]) { + if (l >= r) { + lastNumber = -1; + return; + } + int mid = (l + r) / 2; + if (arr[mid] == x) { + lastNumber = arr[mid - 1]; + return; + } else if (arr[mid] < x && arr[mid + 1] < x) { + find(mid + 1, r, x, arr); + } else if (arr[mid] > x && arr[mid - 1] > x) { + find(l, mid - 1, x, arr); + } else if (arr[mid] < x && arr[mid + 1] > x) { + lastNumber = arr[mid]; + } else if (arr[mid] <= x) { + lastNumber = arr[mid]; + } + return; +} + +int main() { + int n, m; + std::cin >> n >> m; + int arr[n]; + for (auto &i : arr) { + std::cin >> i; + } + while (n > 0) { + int x; + std::cin >> x; + find(0, n, x, arr); + std::cout << lastNumber << std::endl; + n--; + } +} \ No newline at end of file diff --git a/src/algorithm/fenzhi/mianxiangjieguobiancheng.cpp b/src/algorithm/fenzhi/mianxiangjieguobiancheng.cpp new file mode 100644 index 0000000..bde88d2 --- /dev/null +++ b/src/algorithm/fenzhi/mianxiangjieguobiancheng.cpp @@ -0,0 +1,17 @@ +#include +#include + +int main() { + int n, m; + std::cin >> m; + int size = std::pow(2, m); + int arr[size][size]; + for (int i = 0; i < m; i++) { + for (int j = 1 + (i * 2); j <= 2 + (i * 2); j++) { + + arr[j][k] = j + (i * 2); + } + for (int k = 1 + (i * 2); k <= 2 + (i * 2); k++) { + } + } +} \ No newline at end of file diff --git a/src/algorithm/findNumber b/src/algorithm/findNumber new file mode 100755 index 0000000000000000000000000000000000000000..1bdbdfd60d5e09f718e2e03fd19ceae226aac884 GIT binary patch literal 16224 zcmeHOdvIJ;89%#e+F&0^Ybq&Kx|GMXlx*{8Yj~7yo8I&W+O*^WrHZ%P-A%HR?8e=j znlcE1h{MjB5t$J>4rrP2QJisxLB^>lnzqndVIY;NIM#86GP4E677@$CuD|b`^KEXf zSqA!#&Unwxz2EtM-{XAeyN^A0_q%r*8(aK7pWs#|t`)=$S1BZ<1-Vb_4oFBeiP_j+ zC_W{ogP$fbB@ZbAscJ9zC({azmw}R94RxlVpH#45$`KMJyHc&IoMxFi?I<_9Yn8(8)syKSotHdMM#n`k+3nSKd$k?YDs9J< z^GR-KYtr*@(-36TLUJ#J+ipnPx#@bX&y>cX*72$xJ(uyeXuGO_bR*pK3Iz+MJl+kk zqr80B#)r9Gk5}qA^y+*vrQ=O)d0%|Tsuj!oqP2bT#NbfvP}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o!03DEJZv04-#-ZB*rlP~?Q2w>SuP=u%eu6zcd1Cx)AYrJ#_N5> JO~lRozX6mQl@ +#include + +bool findNumber(int list[], int low, int high, int x) { + bool flag; + if (low < high) { + int mid = low + (high - low) / 2; + if (list[mid] == x) { + std::cout << "YES" << std::endl; + exit(0); + } else if (list[mid] < x) { + flag = findNumber(list, low, mid - 1, x); + } else { + flag = findNumber(list, mid + 1, high, x); + } + return flag; + } + std::cout << "NO" << std::endl; + exit(1); +} + +int main() { + int n, x; + std::cin >> n >> x; + int listn[n]; + for (int i = 0; i < n; i++) { + std::cin >> listn[i]; + } + findNumber(listn, 0, n - 1, x); + return 0; +} \ No newline at end of file diff --git a/src/algorithm/hanoi b/src/algorithm/hanoi new file mode 100755 index 0000000000000000000000000000000000000000..069a67585cbda40b8925489377e1c47a5d0a6ad2 GIT binary patch literal 15936 zcmeHOU2GKB6~4R1U?A8g!eF4ms}v(s;>AB;xkSMFXU(|6=Fe`4MLUdl*Y-5tU3Yg3 zCMpS%+tjXwl;k1dArDlFS{kV;QL8phRk{fkjjKKoMQVAdR1zhUQQFj~PUW=7+wa`D zXFML(Rg+3pE6uTH&OP5f-@SLv+?l=OIrCKXa7Qo@5G+OFfFSF1xs60rMXpH|pdzAK ztiyhrcu1^-y+UGkeZ*F%wdGcDsV-4?5j62CsZcP-A-LCvuQy(NJ-nZhProW?#R~eGc2(Ny`h6QWx z?-+O#mw#9IG#^*}Eq5MHt9Y`e^G&jQ*z9lGvwJvRJ8Y&#$7;u#n`)c(gtO^zgRG}< z)nTJKb*Q^n1TTmjVayMRz!E#CY`91v-woI(?8GnLHuUzw$au2PI%yVt>*ml?xj(EW zA36?dlYB@Bqm6}zzXlumsQ3U{Au;mFKEFyGAzAm!_W?b4KP=7yd$<7Jv5f!I%ix!m z!TXlM>3Bofyh6tp@`A8wo)p550begRi%0|oNF_BuqU(dnbV|=!M#j>0p?CIl>G4D+ zF=%G3M5d>!Z8)7u^cela3A?UvO<(s3Gn0)TH-+A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Vh6P3%XGLcopzM z{^4bCF=V9DW;ix7f&}sI6IQd1Y;y|<-i>uSa>K2}U?QViY2MA)sB9qIJP)@nydLnLE26E<)Ad@|Aru5NlBJRn1UqVo6@9}I}M~vc>Z|`K) z+m3b?yNIPnQ2bV3I zp&OZufq@c(%V^k0nlbd6MqAj0We0X+I58p|ODB^FOp5}&FdTP ziG1DiSs1jYz~wKcS@Bs%6wZp*8*I~Ob#DHc;iNbakB;r^jpq+Ue~cMQ30c4q#_?budhsCG-T%UI*~Q63*jQg z8-H3C&>D>SyzXMXQSo^E?8o{^)YF=dZC=;09#MQgM?8K7i;E~wOqtK?O4hut3;q%AX+bAHRQ(gmv@pBh{ujut>oAn>TDRc4px$H_UwYE54 zY-`bG{s*X_xub3y&bpYtKjrUCY5tQikI&;AFgkwb^Y>P{-Q+DqjjfzL^I3n48aJPx z>t+IxwT~nj@A!^(uAy=7->s0^VaWda~ z{c&?{&2!J)w5A%YR0E^mq1D)U{Cxi)jK}WgpKi1*&C@vd%f7U1FT}qhzXlXyqle%z G#XkXbJbzUH literal 0 HcmV?d00001 diff --git a/src/algorithm/hanoi.cpp b/src/algorithm/hanoi.cpp new file mode 100644 index 0000000..c5f3341 --- /dev/null +++ b/src/algorithm/hanoi.cpp @@ -0,0 +1,21 @@ +#include +#include + +int count = 0; + +void mov(int n, char from, char to, char aux) { + if (n == 0) { + return; + } + mov(n - 1, from, aux, to); + count++; + printf("%d:from%c-->%c\n", count, from, to); + mov(n - 1, aux, to, from); +} + +int main() { + int n; + std::cin >> n; + mov(n, 'A', 'C', 'B'); + return 0; +} \ No newline at end of file diff --git a/src/luckyNumber.cpp b/src/luckyNumber.cpp new file mode 100644 index 0000000..5cd37a3 --- /dev/null +++ b/src/luckyNumber.cpp @@ -0,0 +1,37 @@ +#include +#include + +int main() { + int n; + std::cin >> n; + std::string slistn[n]; + for (int i = 0; i < n; i++) { + std::getline(std::cin, slistn[i]); + for (int j = 0; j < slistn[i].size(); j++) { + slistn[i][j] = slistn[i][j] - '0'; + } + } + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + slistn[i][j] *= 7; + } + } + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j += 2) { + while (slistn[i][j] > 9) { + slistn[i][j] = (slistn[i][j] / 10) + (slistn[i][j] % 10); + } + } + } + int sum[n]; + for (int i = 0; i < n; i++) { + for (int j : slistn[i]) { + sum[i] += j; + } + if (sum[i] % 8 == 0) { + std::cout << "T" << std::endl; + } + std::cout << "F" << std::endl; + } + return 0; +} \ No newline at end of file diff --git a/src/type/stringTo b/src/type/stringTo new file mode 100755 index 0000000000000000000000000000000000000000..6795d5b926d9b3c6159f0008df3ad2e1a02caa80 GIT binary patch literal 17584 zcmeHPe{fXQ6~3DU2vtZxr~#_16dBO6WRrkcq;5zyyeMEuf>2ue*z9hSt;ufOeZhs9 z+LVZ8rOZ&qDpT!D>Nv`@I;B6fjJ8fR7K_t%a2y?M|7gaMPBK!(svT;T?RW0IXY=;C z&(X}Ne{}E6d*`0-o^$TG=e>9L-IsIo-Qb3%5|2l4DHUH6#En)eB%mA4U8gG`0kK-l zzPz0^2oG!_ybNYGPN7ZvMKI|d)p|#@ z9@9##$CTqq?$fba$J0pzXrmI4XCa(=X|3m^jar^5^+BcWj1`$oe=S6+i_otVqSFc*Ws?L{6_-dpJ zP zk%~7+hQ>iQNrnnxbZ{Z}$qvb=_*9m7AVC#68J54U~3t+#HohMyz(*@t`V!zhKpO;+hJmzBO&o1(hy4Zi-1*hxi#o;VJ zaj_3G1?9iuf^UJHSz^8z2&f(^$pFe#po9j6LB+Tg_4$O3bVO=qZx@N zqg}C-6-~BpZ0JeEqwS%No~UXo+_HUBTP&Fhw#J0Hz0K-LHHX_Qzdzg^N}5(O6te&X z+d?=6ThUP45lY3vW+G)JqoLmBcC)?O47Ockw%)j@&AP@k!|Al&@2^o(5Q@dSn%nBk zwv}eP-wX!Phr66>#|{4AF6mueG#=?Gxa>XAlM1#pwYDYNOmYWa zcSSAC5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JU-mzrfV_wc)#2kf(;_^M6x&3W5%#UC1fR%%`M?cY*h#b z`})*2hZ{c?>yfD5L}A}7VjmhVTK+zT+%>}`qfH$Uzy=&MxT%qL=FlTRn=0~6Y~S?h zcwa|bOlSZmJ+Eq)1s>iwp4G`bH?;f4?l|4mdb>t$)bzCXU~dez*q9xu6!*E^cJZ;n zW|G%B*g?CCOn-s9N9{ifwl%6CyX~;aa~~T#3O$Vh+kTLb+)9Vcy}n(EqsyPade@ml~gUeu;VC}i03gT+LFj;=zzu`pB; zu#S^YcB#zcb`rjDqPI61xANW}Cd<&e7_Y#&JtxT@o%hc*?(T| zGhM3n@meK|)Bg}qT9UIqe-B{F`+^b@De`S)VgFf<>FsExZvo8n_W-8Hv_APyezN}>76(zGYr^{cJ%XuMJIwvFK9B!i zt-nqifEE%s=YT=XD}e{;tLHPXB+c^*R2+t0gt1>t-)b{U^~#<7a*T9>BEG zu8g`<|D;2|#j6yUE+*r)!q<pP!ch|6N9jxJ>T5p8fl->{bfosNUY&GQdo?7LLdr>d2z@ + +char listn[] = {'a', 'e', 'i', 'o', 'u'}; + +int main() { + int n; + std::cin >> n; + while (n >= 0) { + std::string s; + std::getline(std::cin, s); + for (auto &i : s) { + i = std::tolower(i); + } + for (auto &i : s) { + for (auto j : listn) { + if (i == j) { + i -= 32; + } + } + } + std::cout << s << std::endl; + n--; + } + return 0; +}