Topic links: P1200 [USACO1.1] in your flying saucer here, Your Ride Is Here
Program description:
It's a simple question of water, respectively, with the c and c ++ to do.
Returns a string with a length c ++ getline () function of the input variable value string, length ().
c language memory array of char string, note string terminator. Note c ++ and java-string is not the end of string. strlen () function returns the length of the string, excluding the ending character.
'A' corresponding to the ASCII code is 65, 'a' 97 corresponding to the ASCII code.
code show as below:
#include <iostream>
#include <string>
using namespace std;
int main() {
int p = 1, q = 1;
string a, b;
getline(cin, a);
getline(cin, b);
for(int i = 0; i < a.length(); i++)
p *= a[i] - 64;
for(int i = 0; i < b.length(); i++)
q *= b[i] - 64;
if(q % 47 == p % 47)
cout<<"GO"<<endl;
else
cout<<"STAY"<<endl;
return 0;
}
#include <stdio.h>
#include <string.h>
int main(void) {
int sum1 = 1, sum2 = 1;
char a[7];
char b[7];
scanf("%s", a);
scanf("%s", b);
for(int i = 0; i < strlen(a); i++)
sum1 *= (a[i] - 64);
for(int j = 0; j < strlen(b); j++)
sum2 *= b[j] - 64;
if(sum1 % 47 == sum2 % 47)
printf("GO");
else
printf("STAY");
return 0;
}