当前位置:网站首页>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
边栏推荐
- Dynamic research and future planning analysis report of China's urban water supply industry Ⓝ 2022 ~ 2028
- Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
- DR-NAS26-Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-5GHz-high-power-Mini-PCIe-Wi-Fi-Module
- Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)
- Yyds dry goods inventory Spring Festival "make" your own fireworks
- 2022 safety officer-a certificate registration examination and summary of safety officer-a certificate examination
- Redis concludes that the second pipeline publishes / subscribes to bloom filter redis as a database and caches RDB AOF redis configuration files
- Data consistency between redis and database
- (POJ - 2912) rochambau (weighted concurrent search + enumeration)
- 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
猜你喜欢
Why use pycharm to run the use case successfully but cannot exit?
Summary of basic knowledge of exception handling
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
[SRS] build a specified version of SRS
Common SQL sets
6.0 kernel driver character driver
Code in keil5 -- use the code formatting tool astyle (plug-in)
Mysql database - Advanced SQL statement (I)
Data consistency between redis and database
On my first day at work, this API timeout optimization put me down!
随机推荐
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
Compréhension de la technologie gslb (Global Server load balance)
2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
string
English topic assignment (28)
Oil monkey plug-in
The latest analysis of R1 quick opening pressure vessel operation in 2022 and the examination question bank of R1 quick opening pressure vessel operation
Dahua series books
LeetCode 1647. Minimum deletion times of unique character frequency
Nacos common configuration
STM32 multi serial port implementation of printf -- Based on cubemx
Netfilter ARP log
2022 safety officer-b certificate examination summary and safety officer-b certificate simulation test questions
What indicators should be paid attention to in current limit monitoring?
Analysis report on the development prospect and investment strategy of global and Chinese modular automation systems Ⓟ 2022 ~ 2027
IPhone development swift foundation 09 assets
Control loop of program (while loop)
JS closure knowledge points essence
Rest reference
Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027