好車牌(模擬)


Description

煙台最近使用一種新的車牌號碼: ABC-0123(3個字母+4個數字)

如果字母部分和數字部分差值的絕對值最多為100則認為是好車牌。

字母部分的值的以26進制(A……Z表示)計算。比如第一部分為"ABC",它的值為28(0*26^2 + 1*26^1 + 2*26^0)。因為 |28-123|<=100,所以"ABC-0123"為好車牌。

給出一系列的車牌,你編個程序計算一下哪些是好車牌,哪些不是。

 

Input

第一行為整數N(1<=N<=100),表示車牌的個數。

接下來是N行,每行一個格式為LLL-DDDD的車牌。

 

Output

對每個車牌輸出 "nice" or "not nice" (不包含引號)

 

Sample Input

2
ABC-0123
AAA-9999

Sample Output

nice
not nice


 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<math.h>
 4 #include<stdlib.h>
 5 int main()
 6 {
 7     int t,s1,s2,ans,i,sum;
 8     char s[10];
 9     scanf("%d",&t);
10     getchar();
11     while(t--)
12     {
13         gets(s);
14         s2=0;
15         s1=0;
16         for(i=0;i<=2;i++)
17         {
18             s1=s1*26+(s[i]-65);
19         }
20         for(i=4;i<=7;i++)
21         {
22             s2=s2*10+s[i]-48;
23         }
24         sum=abs(s1-s2);
25         if(sum<=100)
26             printf("nice\n");
27         else
28             printf("not nice\n");
29     }
30     return 0;
31 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM