• 周日. 5月 26th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

洛谷-小书童——密码-简单字符串

admin

11月 28, 2021
题目背景 Background
某蒟蒻迷上了“小书童”,有一天登陆时忘记密码了(他没绑定邮箱or手机),于是便把问题抛给了神犇你。
 题目描述 Description
蒟蒻虽然忘记密码,但他还记得密码是由一串字母组成。且密码是由一串字母每个向后移动n为形成。他现在找到了移动前的那串字母及n,请你求出密码。
 输入输出格式 Input/output
输入格式:
第一行:n。第二行:未移动前的一串字母
输出格式:
一行,是此蒟蒻的密码
 输入输出样例 Sample input/output
样例测试点#1
输入样例:

1
qwe

输出样例:

rxf

思路:这题简单,只需把字母向后移动几位就得了,注意,这题是要对位数取模,如果大于z或大于Z,取模26。

记住,不是减去26,而是取模,这考虑到了如果要移100或者更多的情况,否则会只得40分的(不要问我为什么知道,因为你懂得^_^),还要考虑大小写的情况!

代码如下:

#include <stdio.h>  
#include <string.h>  
int main()  
{  
    char a[300];  
    int n,i;  
    scanf("%d",&n);  
    scanf("%s",a);  
    for(i=0;i<strlen(a);i++)  
    {  
        if(a[i]>='A'&&a[i]<='Z')//大写   
        {  
            a[i]=((a[i]-65+n)%26)+65;//取模,+65 
        }  
        else //小写   
        {  
            a[i]=((a[i]-97+n)%26)+97;  
        }         
    }  
    puts(a);  
    return 0;  
}  

《洛谷-小书童——密码-简单字符串》有25个想法
  1. From the insightful commentary to the captivating writing, every word of this post is top-notch. Kudos to the author for producing such fantastic content.

  2. I am absolutely thrilled to introduce you to the incredible Sumatra Slim Belly Tonic! This powdered weight loss formula is like no other, featuring a powerful blend of eight natural ingredients that are scientifically linked to fat burning, weight management, and overall weight loss. Just imagine the possibilities! With Sumatra Slim Belly Tonic, you have the opportunity to finally achieve your weight loss goals and transform your body into the best version of yourself.

  3. I am absolutely thrilled to introduce you to the incredible Sumatra Slim Belly Tonic! This powdered weight loss formula is like no other, featuring a powerful blend of eight natural ingredients that are scientifically linked to fat burning, weight management, and overall weight loss. Just imagine the possibilities! With Sumatra Slim Belly Tonic, you have the opportunity to finally achieve your weight loss goals and transform your body into the best version of yourself.

  4. Your honesty and vulnerability in sharing your personal experiences is truly admirable It takes courage to open up and I applaud you for it

  5. I am absolutely thrilled to introduce you to the incredible Sumatra Slim Belly Tonic! This powdered weight loss formula is like no other, featuring a powerful blend of eight natural ingredients that are scientifically linked to fat burning, weight management, and overall weight loss. Just imagine the possibilities! With Sumatra Slim Belly Tonic, you have the opportunity to finally achieve your weight loss goals and transform your body into the best version of yourself.

  6. It means so much to receive positive feedback and know that my content is appreciated. I strive to bring new ideas and insights to my readers.

  7. GlucoTrust is a powerful dietary supplement that is designed to address the root cause of excessive blood sugar. It provides the body with essential vitamins and minerals that are specifically formulated to lower blood sugar levels and help keep them at optimal levels. This supplement is highly effective in eliminating fat from the liver, pancreas, and cells, which is one of the primary causes of high blood sugar levels. By doing so, it improves the conversion of carbohydrates and proteins into energy that your body can easily burn.

  8. Sugar Defender orchestrates a reduction in blood sugar levels through multifaceted pathways. Its initial impact revolves around enhancing insulin sensitivity, optimizing the body’s efficient use of insulin, ultimately leading to a decrease in blood sugar levels. This proactive strategy works to prevent the storage of glucose as fat, mitigating the risk of developing type 2 diabetes.

  9. I couldn’t stop scrolling and reading, your content is truly one-of-a-kind. Thank you for all the time and effort you put into creating such amazing content.

  10. Introducing Alpilean, a revolutionary weight loss solution dedicated to assisting you in shedding those unwanted pounds through a safe and organic approach. This exceptional supplement is meticulously crafted to synchronize with your body’s innate metabolism, elevating fat-burning capabilities while effectively curbing your appetite. The cornerstone of Alpilean’s success lies in its potent component, alpha-lipoic acid, a remarkable antioxidant renowned for its ability to foster weight loss by enhancing insulin sensitivity and decreasing glucose absorption within the body. Embrace Alpilean and embark on a transformative journey towards a healthier and more vibrant you.

  11. Sugar Defender’s prowess in managing blood sugar is deeply rooted in its exceptional blend of natural ingredients, each playing a distinct role that contributes to the overall success of the supplement. Here are some noteworthy positive impacts of the Sugar Defender Ingredients blend:

  12. Sugar Defender’s prowess in managing blood sugar is deeply rooted in its exceptional blend of natural ingredients, each playing a distinct role that contributes to the overall success of the supplement. Here are some noteworthy positive impacts of the Sugar Defender Ingredients blend:

  13. Metanail Complex is an innovative nail care product that is designed to improve the strength and appearance of nails. It is a unique formula that combines nourishing ingredients and powerful antioxidants to promote healthy nail growth and address common nail problems such as brittleness, peeling, and slow growth.

  14. We just wanted to take a moment to acknowledge all the hard work and effort you’ve been putting in lately. Keep up the amazing job, you’re doing great!

  15. Wow, awesome weblog format! How lengthy have you ever been blogging for?
    you made blogging glance easy. The whole glance of your web site
    is magnificent, as smartly as the content material!
    You can see similar here ecommerce

  16. Hey There. I discovered your blog using msn. That is an extremely well written article.
    I’ll be sure to bookmark it and come back to read more of your useful information. Thank you for the post.
    I’ll certainly return. I saw similar here: Sklep internetowy

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注