当前位置:网站首页>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
边栏推荐
- Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
- Sed、Awk
- Oil monkey plug-in
- Leetcode problem solving - 230 The k-th smallest element in the binary search tree
- DR-NAS26-Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-5GHz-high-power-Mini-PCIe-Wi-Fi-Module
- Report on the development status and investment planning trends of China's data center industry Ⓡ 2022 ~ 2028
- Sow of PMP
- Team collaborative combat penetration tool CS artifact cobalt strike
- [secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
- 国泰君安证券开户是安全可靠的么?怎么开国泰君安证券账户
猜你喜欢
Common SQL sets
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
Buuctf, web:[geek challenge 2019] buyflag
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
What is the difference between res.send() and res.end() in the node express framework
UC Berkeley proposes a multitask framework slip
Buuctf, misc: sniffed traffic
Mysql database - Advanced SQL statement (I)
Cesium terrain clipping draw polygon clipping
随机推荐
Introduction to kubernetes
Pooling idea: string constant pool, thread pool, database connection pool
China HDI market production and marketing demand and investment forecast analysis report Ⓢ 2022 ~ 2028
[sg function] 2021 Niuke winter vacation training camp 6 h. winter messenger 2
Summary of basic knowledge of exception handling
Station B, dark horse programmer, employee management system, access conflict related (there is an unhandled exception at 0x00007ff633a4c54d (in employee management system.Exe): 0xc0000005: read locat
An expression that regularly matches one of two strings
Ansible common usage scenarios
Bluebridge cup Guoxin Changtian single chip microcomputer -- detailed explanation of schematic diagram (IV)
regular expression
[actual combat record] record the whole process of the server being attacked (redis vulnerability)
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Remember the experience of automatically jumping to spinach station when the home page was tampered with
LeetCode 540. A single element in an ordered array
Electronic tube: Literature Research on basic characteristics of 6j1
Functions and differences between static and Const
Intimacy communication -- [repair relationship] - use communication to heal injuries
How PHP drives mongodb
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
Codeforces Round #768 (Div. 1)(A-C)