1012. 变换密码

题目描述

一密码变换规则如下:一个正整数对应一个字符;如果该数模123的值在97-122范围,变换为ASCII为该余数对应的小写字符;如果变换不了小写字符,将该数模91,若余数在65-90范围,变换为ASCII为该余数对应的大写字符;如果变换不了大小写字符,变换为“*”。输入一个正整数,输出变换后的字符。

输入

输入一个正整数n(1<=n<=1000)表示原始密码。

输出

输出变换后的密码。

样例输入

42

样例输出

*

数据范围限制

1<=n<=1000
 1 #include<iostream>
 2 #include<cmath>
 3 #include<cstdio>
 4 using namespace std;
 5 int tot=0;
 6 double ans;
 7 int main()
 8 {
 9     int n;
10     cin>>n;
11     if(n%123>=97&&n%123<=122)
12     {
13         cout<<(char)(n%123);
14         return 0;
15     }
16     else if(n%91>=65&&n%91<=90)
17     {
18         cout<<(char)(n%91);
19         return 0;
20     }
21     else cout<<"*";
22     return 0;
23 }
原文地址:https://www.cnblogs.com/zwfymqz/p/6636789.html