mirror of
https://github.com/mx42/codingame.git
synced 2026-01-14 05:39:51 +01:00
Adding easy puzzles
This commit is contained in:
53
puzzles/easy/ascii-art.cpp
Normal file
53
puzzles/easy/ascii-art.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// https://www.codingame.com/training/easy/ascii-art
|
||||
// Xavier Morel - 2014-10-16
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector<string> letters;
|
||||
|
||||
/**
|
||||
* Auto-generated code below aims at helping you parse
|
||||
* the standard input according to the problem statement.
|
||||
**/
|
||||
int main()
|
||||
{
|
||||
int L;
|
||||
cin >> L; cin.ignore();
|
||||
int H;
|
||||
cin >> H; cin.ignore();
|
||||
string T;
|
||||
getline(cin, T);
|
||||
|
||||
|
||||
for (int i = 0; i < H; i++) {
|
||||
string ROW;
|
||||
getline(cin, ROW);
|
||||
letters.push_back(ROW);
|
||||
}
|
||||
|
||||
for (char &c : T) {
|
||||
// Handling char.
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c -= 'a';
|
||||
} else if (c >= 'A' && c <= 'Z') {
|
||||
c -= 'A';
|
||||
} else {
|
||||
c = 26; // ?
|
||||
}
|
||||
}
|
||||
|
||||
// Write an action using cout. DON'T FORGET THE "<< endl"
|
||||
// To debug: cerr << "Debug messages..." << endl;
|
||||
|
||||
for (int i = 0; i < H; i++) {
|
||||
for (char c : T) {
|
||||
cout << letters[i].substr((c*L), L);
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user