n a^o7 ! (简单的字符串处理)

本文介绍了一个有趣的编程挑战,参与者需要编写程序来逆序转换特定字符串,并从中解读出隐藏的爱情信息。挑战通过一系列输入输出示例展示了如何将看似无意义的字符转化为浪漫的情书。

1、题目:

n a^o7 !

Time Limit: 1000MS    Memory limit: 65536K

题目描述

All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my instructions, which can make you in the best state preparing to fight. Now please relax yourself and enjoy the good moment. Before you raise your sharp sword to the enemy who guards the battleground, please allow me to tell you a true and romantic story about a samurai like you.
Samurai hh fell in love with girl ss, who is charming and demure. He realized the truth that he must spend his remaining life with ss, and resolved to pursue the hard-won affection. One day hh wrote a letter to ss, when she opens the letter with excitement her mind was in tangle. She found herself completely not to figure out the meaning about the letter, which said that "n 55!w ! pue n a^o7 ! n paau !". ss also immersed herself in guessing the meaning of that letter for a long time because of her adore to hh. Finally she called hh to ask the meaning of the letter. On the other side of the phone, hh was too nervous to say. Gradually he calmed down himself and told ss to reverse the letter and read it. Then on both ends of the phone comes the voice at the same time "i need u i love u and i miss u".
ss wants to tell each of you however you are Brave And Skilled, you shouldn't forget to express your loyal love and romantic feelings to your prince or princess.
Now the horn sounds for battle,do it by the following input and output. I think each of you will get an "Accepted" in this battle with pleasant mood.

输入

Input contains an integer T in the first line, and then T lines follow .Each line contains a message (only contain 'n5!wpuea^o7!' and
' '(space)), the message's length is no more than 100.

输出

Output the case number and the message. (As shown in the sample output)

示例输入

2n 55!w ! pue n a^o7 ! n paau !n5!wpuea^o7

示例输出

Case 1: i need u i love u and i miss uCase 2: loveandmisu

 

2、代码:

#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d",&n);
    for(int cas=1;cas<=n;cas++)
    {
        char s[110];
        if(cas==1)
        getchar();

        //scanf("%s",s);
        gets(s);
        //printf("%s\n",s);
        printf("Case %d: ",cas);
        for(int i=strlen(s)-1;i>=0;i--)
        {
            if(s[i]=='n')
            printf("u");
            if(s[i]=='5')
            printf("s");
            if(s[i]=='!')
            printf("i");
            if(s[i]=='w')
            printf("m");
            if(s[i]=='p')
            printf("d");
            if(s[i]=='u')
            printf("n");
            if(s[i]=='e')
            printf("a");
            if(s[i]=='a')
            printf("e");
            if(s[i]=='^')
            printf("v");
            if(s[i]=='o')
            printf("o");
            if(s[i]=='7')
            printf("l");
            if(s[i]==' ')
            printf(" ");
        }
        printf("\n");
    }
    return 0;
}


 

你和fjy学姐是星际旅行团的领队,负责为团队选择一个适合的星球进行观光。每个星球都有独特的环境特征,这些特征会影响旅行的舒适度和趣味性。请你依次完成以下任务,并输出最终结果。 任务一:解码星球环境 每个星球环境用一个 4 字符 的编码 s1 s2 s3 s4 表示,每个字符对应不同的环境特征: s1(大气层) 如果是 'O' 或 'o',表示该星球有氧气(适合人类呼吸)。 如果是 'N' 或 'n',表示该星球有氮气(需要呼吸设备)。 如果是 'C' 或 'c',表示该星球有有毒物质(危险,不适合停留)。 s2(温度) 如果是数字 '0'-'4',表示极寒(温度低于 -50°C)。 如果是数字 '5'-'9',表示温暖(温度在 0°C 到 50°C 之间)。 如果是字母 'A'-'F' 或 'a'-'f',表示炎热(温度高于 50°C)。 s3(光照) 如果是 'D' 或 'd',表示黑暗(几乎没有阳光)。 如果是 'B' 或 'b',表示明亮(适合观光)。 如果是 'F' 或 'f',表示极光(适合摄影)。 s4(生命迹象) 如果是 'Y' 或 'y',表示有外星人(可能危险)。 如果是 'N' 或 'n',表示无生命(安全但无聊)。 任务二:获得数字符号 请根据以下规则将各环境参数转换为对应的数字: 大气层(s1) 氧气(O/o):6 氮气(N/n):3 有毒物质(C/c):-1(直接排除) 其他情况:0 温度(s2) 极寒(0-4):2 温暖(5-9):4 炎热((A-F)/(a-f)):1 其他情况:0 光照(s3) 黑暗(D/d):1 明亮(B/b):4 极光(F/f):6 其他情况:0 生命迹象(s4) 有外星人(Y/y):5 无生命(N/n):3 其他情况:0 任务三:计算得分 你得到了没有被排除的几个星球的编码信息,你需要根据以下规则算出这几个星球的环境得分 环境得分=基础得分+额外得分 基础得分: 环境的基础得分为阶乘之和,例: 获得数字符号为:6,2,0,3,那么基础得分为 6! + 2! + 0! + 3! = 729 额外得分: 如果星球同时有氧气和温暖温度,额外 +10 分。 如果星球有极光但无生命,额外 +15 分(适合摄影)。 如果星球有外星生物且温度炎热,额外 -125 分(危险)。 排除规则: 如果星球 有有毒物质(C/c),直接排除(不计算得分)。 如果星球的环境得分是质数 或者 小于等于0,直接排除 任务四:选择最佳星球 从所有未被排除的星球中,选择得分最高的一个。 如果多个星球得分相同,选择编号最小的。 如果多个星球得分相同且编号相同,选择输入顺序中最先出现的。 如果没有符合条件的星球,输出 "What @ plty!"(不含双引号),并且不再进行后续的收集水晶活动 任务五:收集水晶 游戏规则: 星球表面分布着 k 个水晶(用整数表示能量值),需要从左到右依次收集水晶 从第二个水晶开始,需要计算当前水晶能量与上一个水晶能量的差值作为"寻宝积分"(注意:若k = 1,寻宝积分为0) 最终目标是计算总寻宝积分(所有相邻水晶能量差的值之和) 最终得分为该星球得分加上收集水晶过程的总寻宝积分 输入 第一行一个整数n,表示景点的数量 接下来n行,每行一个整数num,四个字符,s1,s2,s3,s4,一个整数k,k个整数,分别表示景点编号为i的景点,对应的编码,水晶的个数,每个水晶ki的能量值 输出 若不存在满足条件的景点,输出 "What @ plty!" (不含双引号) 否则第一行输出两个整数,分别表示景点编号和最终得分 若最终得分小于等于10,在第二行输出 "Luohualiushui!" (不含双引号) 输入样例 1 3 1 O5Bn 3 10 20 30 2 C6Fn 2 5 15 3 o7Dy 4 100 200 300 400 输出样例 1 3 1175 输入样例 2 2 1 C5ON 1 1 2 N7F0 3 5 2 0 输出样例 2 What @ plty! 输入样例 3 3 1 O5ON 3 1 2 3 2 N6Fn 4 800 400 200 20 3 a7Dy 1 5 输出样例 3 2 -9 Luohualiushui! 提示 保证基础得分,额外得分,最终得分在int的数据范围内 1≤n≤100 −2^63≤num≤2^63 − 1 1≤k≤100 -2^31≤ki≤2^31 - 1
10-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值