C#解答:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CPE_3test
{
class _12602_car
{
public static void Main(string[] args)
{
char[] abc = new char[] { 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
'R', 'S', 'T', 'U', 'V', 'W', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z' };
int count = Convert.ToInt32(Console.ReadLine());
int sum = 0;
string msg = "";
for (int intA = 0; intA < count; intA++)
{
string[] stamp = Console.ReadLine().Split('-');
char[] abcd = stamp[0].ToCharArray();
for (int intB = 0; intB < abcd.Length; intB++)
{
for (int intC = 0; intC < abc.Length; intC++)
{
if (abcd[intB] == abc[intC] && intB == 0) sum += intC * 26 * 26;
if (abcd[intB] == abc[intC] && intB == 1) sum += intC * 26 ;
if (abcd[intB] == abc[intC] && intB == 2) sum += intC ;
}
}
int num = Convert.ToInt32(stamp[1]);
sum = sum - num;
if (sum < 0) sum = sum * -1;
if (msg != "") msg += Environment.NewLine;
if (sum <= 100) msg += "nice";
else msg += "not nice";
}
Console.WriteLine(msg);
}
}
}
沒有留言:
張貼留言