题目:这是洛谷的第17道题目,将输入的字符串提取出来,转换成小写的字符,进行乘法运算,然后比较两个数与47的求余即可。
源代码:
#include <iostream>
#include <string.h>
#include <sstream>
#include <stdlib.h>
using namespace std;
#define MIDDLE 64
#define VALUE 47
int main()
{
int sum1 = 1,sum2 = 1;
string first, second;
cin >> first;
cin >> second;
char * str1 = new char[first.size()];
char * str2 = new char[second.size()];
strcpy(str1, first.c_str());
strcpy(str2, second.c_str());
for (size_t i = 0; i < first.size(); i++)
sum1 *= str1[i] - MIDDLE;
for (size_t i = 0; i < second.size(); i++)
sum2 *= str2[i] - MIDDLE;
if (sum1%VALUE == sum2%VALUE)
cout << "GO" << endl;
else
cout << "STAY" << endl;
system("pause");
return 0;
}