题目217 a letter and a number

本文介绍了一个简单的字符转换程序,该程序使用C语言实现,能够根据不同条件将输入的字符进行特定的数值转换,并输出转换后的结果。通过对代码的分析,读者可以了解到基本的输入输出操作、条件判断等编程技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

     已AC代码:

#include<cstdio>
using namespace std;

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        char x;
        int y;
        getchar();
        scanf("%c%d", &x, &y);
        if(x>64 && x<91)
            printf("%d\n", x-64+y);
        if(x>96 && x<123)
            printf("%d\n", -(x-96)+y);
    }
    return 0;
}
        


We have come up with the best possible language here at Google, called Googlerese. To translate text into Googlerese, we take any message and replace each English letter with another English letter. This mapping is one-to-one and onto, which means that the same input letter always gets replaced with the same output letter, and different input letters always get replaced with different output letters. A letter may be replaced by itself. Spaces are left as-is. For example (and here is a hint!), our awesome translation algorithm includes the following three mappings: 'a' -> 'y', 'o' -> 'e', and 'z' -> 'q'. This means that "a zoo" will become "y qee". Googlerese is based on the best possible replacement mapping, and we will never change it. It will always be the same. In every test case. We will not tell you the rest of our mapping because that would make the problem too easy, but there are a few examples below that may help. Given some text in Googlerese, can you translate it to back to normal text? 输入 The first line of the input gives the number of test cases, T. T test cases follow, one per line. Each line consists of a string G in Googlerese, made up of one or more words containing the letters 'a' - 'z'. There will be exactly one space (' ') character between consecutive words and no spaces at the beginning or at the end of any line. 1 ≤ T ≤ 30. G contains at most 100 characters. None of the text is guaranteed to be valid English. 输出 For each test case, output one line containing "Case #X: S" where X is the case number and S is the string that becomes G in Googlerese. 样例 输入样例 1 复制 3 ejp mysljylc kd kxveddknmc re jsicpdrysi rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd de kr kd eoya kw aej tysr re ujdr lkgc jv 输出样例 1 Case #1: our language is impossible to understand Case #2: there are twenty six factorial possibilities Case #3: so it is okay if you want to just give up给出这个问的思路,用C语言
最新发布
06-11
老师教学上字典和元组是这样的“在需要使⽤序列的情况下: • 函数的返回值 • 字典的键值 • 函数的参数 directory[last, first] = number • for last, first in directory: • print(first, last, directory[last,first]) def has_match(t1, t2): • for x, y in zip(t1, t2): • if x == y: • return True • return False • for index, element in enumerate('abc'): • print(index, element)请你基于老师教学的代码完成练习12-2 “Exercise 12-2. More anagrams! 148 | Chapter 12: Tuples 1. Write a program that reads a word list from a file (see "Reading Word Lists" on page 99) and prints all the sets of words that are anagrams. Here is an example of what the output might look like: ['deltas', 'desalt', 'lasted', 'salted', 'slated', 'staled'] ['retainers' ['renerating greatening , 'greatening'] ['resmelts' , 'smelters' , 'termless'] Hint: you might want to build a dictionary that maps from a collection of letters to a list of words that can be spelled with those letters. The question is, how can you represent the collection of letters in a way that can be used as a key? 2. Modify the previous program so that it prints the longest list of anagrams first, followed by the second longest, and so on. 3. In Scrabble, a "bingo" is when you play all seven tiles in your rack, along with a letter on the board, to form an eight-letter word. What collection of eight letters forms the most possible bingos? Hint: there are seven.”请你运用python运行规则 编写练习12-2要求的运行代码 注意代码编写具有可读性和完整性 能够真实运行出符合要求的数据 注意分两版答案 第一版应该有注释 第二版为纯代码 其中题目有说明解的思路 可以按照题目的思路步骤一步一步完成
06-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值