#21236: C++解答


abs71507@gmail.com (46 5)

學校 : 國立中興大學
編號 : 87742
來源 : [36.235.200.136]
最後登入時間 :
2023-05-24 14:06:42
e975. 3. 情書解密 (Love) -- 2019年5月TOI練習賽新手組 | From: [27.246.42.199] | 發表日期 : 2020-05-05 01:53

#include <iostream>

#include <string>

#include <cctype>

using namespace std;

int main(void)

{

bool vac=true,check=false;

char tran[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

int num[1000] = { 0 };

int love[4] = { 12,15,22,5 };

string input;

while (getline(cin, input))

{

int counter = 0;

for (int i = 0; i < input.length(); i++)

{

vac = false;

if (isupper(input[i]))

input[i] = tolower(input[i]);

for (int j = 0; j <=25; j++)

{

if (tran[j] == input[i])

{

num[counter] = j + 1;

vac = true;

break; 

}

}

if(vac==true)counter++;

}

for (int i = 0; i <= 25; i++)

{

for (int k = 0; k < counter-3; k++)

{

if (num[k] == love[0])

{

check = true;

for (int g = 1; g <= 3; g++)

{

if (num[k + g] != love[g])

{

check = false;

break;

}

}

}

else check = false;

if (check == true)

{

cout << i << endl;

break;

}

}

for (int j = 0; j < counter; j++)

{

num[j]++;

if (num[j] == 27)num[j] = 1;

}

}

}

return 0;

}

 
ZeroJudge Forum