当前位置:网站首页>Pat grade A - 1164 good in C (20 points)
Pat grade A - 1164 good in C (20 points)
2022-07-03 22:16:00 【White speed Dragon King's review】

subject
give A-Z And a sentence , Output word segmentation sentences in matrix form
Ideas
Three dimensional array saves every letter
Then splice it together
Pit point
The space may also be seperator
use getchar()+getline() Get the whole row
src:
#include<bits/stdc++.h>
using namespace std;
// Every English letter is 7 * 5 One of the matrix
char word[26][7][5];
int main() {
for(int i = 0; i < 26; i++) {
for(int j = 0; j < 7; j++) {
for(int k = 0; k < 5; k++) {
cin >> word[i][j][k];
}
}
}
string sentence;
getchar();
// The space may also be seperator
getline(cin, sentence);
vector<string> v;
int left = 0;
int right = 0;
while(left < sentence.size()) {
if(sentence[left] < 'A' || sentence[left] > 'Z') {
++left;
right = left;
}
else {
while(right < sentence.size() && sentence[right] >= 'A' && sentence[right] <= 'Z')
right++;
v.push_back(sentence.substr(left, right - left));
left = right;
}
}
//cout << v[1] << endl;
for(int i = 0; i < v.size(); i++) {
char ans[7][200];
int wordLen = v[i].size();
for(int j = 0; j < wordLen; j++) {
int index = v[i][j] - 'A';
for(int p = j * 6; p < (j + 1) * 6; p++) {
for(int q = 0; q < 7; q++) {
if(p == (j + 1) * 6 - 1) ans[q][p] = ' ';
else {
ans[q][p] = word[index][q][p % 6];
}
}
}
}
// Output the result of this line
for(int q = 0; q < 7; q++) {
for(int j = 0; j < wordLen * 6 - 1; j++) {
cout << ans[q][j];
}
cout << endl;
}
if(i != v.size() - 1) cout << endl;
}
return 0;
}
summary :
And manually split
cpp It's really inconvenient
边栏推荐
- JS Demo calcule combien de jours il reste de l'année
- Sow of PMP
- An expression that regularly matches one of two strings
- Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
- 1 Introduction to spark Foundation
- [golang] leetcode intermediate - alphabetic combination of island number and phone number
- Report on the development status and investment planning trends of China's data center industry Ⓡ 2022 ~ 2028
- Rest reference
- Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
- 4 environment construction -standalone ha
猜你喜欢

The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation

How PHP gets all method names of objects

Electronic tube: Literature Research on basic characteristics of 6j1

4 environment construction -standalone ha

Preliminary analysis of smart microwave radar module
![[golang] leetcode intermediate - alphabetic combination of island number and phone number](/img/40/a664ea866ce355c1f5e9305fe91780.jpg)
[golang] leetcode intermediate - alphabetic combination of island number and phone number
![Buuctf, web:[geek challenge 2019] buyflag](/img/02/d3add04f8145621bff35d46b82ba53.jpg)
Buuctf, web:[geek challenge 2019] buyflag

Dahua series books
![[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)](/img/6c/2d48d441fee1981a271319fd9f6c23.jpg)
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
![[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list](/img/db/b992d2b461ca17652518a1511b4947.gif)
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
随机推荐
WiFi 2.4g/5g/6g channel distribution
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
Décompiler et modifier un exe ou une DLL non source en utilisant dnspy
Investment analysis and prospect trend prediction report of China's boron nitride industry Ⓨ 2022 ~ 2028
China HDI market production and marketing demand and investment forecast analysis report Ⓢ 2022 ~ 2028
Preliminary analysis of smart microwave radar module
The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation
The 14th five year plan and investment feasibility study report of China's industry university research cooperation Ⓧ 2022 ~ 2028
Miscellaneous things that don't miss the right business
China's TPMS industry demand forecast and future development trend analysis report Ⓐ 2022 ~ 2028
2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units
JS notes (III)
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
Code in keil5 -- use the code formatting tool astyle (plug-in)
DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power
Common SQL sets
How PHP gets all method names of objects
BUUCTF,Misc:LSB
Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027
Electronic tube: Literature Research on basic characteristics of 6j1