zoukankan      html  css  js  c++  java
  • 算法提高 9-2 文本加密

      算法提高 9-2 文本加密  
    时间限制:1.0s   内存限制:256.0MB
     
       
    问题描述
      先编写函数EncryptChar,按照下述 规则将给定的字符c转化(加密)为新的字符:"A"转化"B","B"转化为"C",... ..."Z"转化为"a","a"转化为"b",... ..., "z"转化为"A",其它字符不加密。编写程序,加密给定字符串。
    样例输出
    与上面的样例输入对应的输出。
    例:
    数据规模和约定
      输入数据中每一个数的范围。
      例:50个字符以内无空格字符串。
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <vector>
    #include <queue>
    #include <cstring>
    #include <algorithm>
    #include <cstdlib>
    #define for(i,x,n) for(int i=x;i<n;i++)
    #define ll long long int
    #define INF 0x3f3f3f3f
    #define MOD 1000000007
    #define MAX_N 50005
    
    using namespace std;
    
    
    int main()
    {
        //freopen("input.txt", "r", stdin);
        //freopen("data.out", "w", stdout);
        char a[100];
        scanf("%s",a);
        int len=strlen(a);
        for(i,0,len){
            if(a[i]=='Z'){
                a[i]='a';
            }else if(a[i]=='z'){
                a[i]='A';
            }else if(a[i]>=65 &&a[i]<=90 || a[i]>=97&&a[i]<=122){
                a[i]+=1;
            }else {
                continue;
            }
        }
        printf("%s",a);
        //fclose(stdin);
        //fclose(stdout);
        return 0;
    }
    //
  • 相关阅读:
    SQL数据库——存储过程
    常用命令
    八大排序算法
    Java 反射的理解
    Java 集合的理解(持续更新......)
    JAVA 用数组实现 ArrayList
    JVM 运行时的内存分配
    Java中的增强 for 循环 foreach
    Java 泛型
    《七》随机访问文件流
  • 原文地址:https://www.cnblogs.com/TWS-YIFEI/p/6368188.html
Copyright © 2011-2022 走看看