Problem C 凯撒加密

116 篇文章 2 订阅
45 篇文章 9 订阅

Problem Description
已知的最古老的一种加密技术是凯撒加密。该方法把一条消息中的每个字母用字母表中固定距离之后的那个字母来替代。如果越过了字母Z,会绕回到字母表的起始位置。例如,如果每个字母都用字母表中两个位置之后的字母代替,那么Y就被替换为A,Z就被替换为B。
编写程序用凯撒加密方法对消息进行加密。
注意:不是字母的字符不变,不改变字母的大小写。
Input Description
第一行输入待加密的消息(不超过100个字符)。
第二行输入一个整数n(1<=n<=25)。表示每个字母都用字母表中 n 个位置之后的字母代替。
Output Description
在一行中输出加密之后的消息。
Sample Input
Go ahead, make my day.
3
Sample Output
Jr dkhdg, pdnh pb gdb.

 

#include <stdio.h>
#define N 200
int main()
{
    int i, j, n, x;
    char a[N];
    for(i = 0; ; i++)
    {
        scanf("%c", &a[i]);
        x = i;
        if(a[i] == '\n')
            break;
    }
    scanf("%d", &n);
    for(j = 0; j <= i; j++)
    {
        if(a[j] >= 'A' && a[j] <= 'Z')
            a[j] = ((a[j] + n - 'A') % 26) + 'A';
        else if(a[j] >= 'a' && a[j] <= 'z')
            a[j] = ((a[j] + n - 'a') % 26) + 'a';

        printf("%c", a[j]);
    }



    return 0;
}

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
Problem_C_Data.zip The three data sets provided contain product user ratings and reviews extracted from the Amazon Customer Reviews Dataset thru Amazon Simple Storage Service (Amazon S3). hair_dryer.tsv microwave.tsv pacifier.tsv Data Set Definitions: Each row represents data partitioned into the following columns. Problem_C_Data.zip提供的三个数据集包含产品用户评分和通过Amazon Simple Storage Service(Amazon S3)从Amazon客户评论数据集提取的评论。 hair_dryer.tsv微波.tsv pacifier.tsv数据集定义:每行代表划分为以下各列的数据。 ● marketplace (string): 2 letter country code of the marketplace where the review was written. ●市场(字符串):撰写评论的市场的2个字母的国家代码。 ● customer_id (string): Random identifier that can be used to aggregate reviews written by a single author. ●customer_id(字符串):随机标识符,可用于汇总单个作者撰写的评论。 ● review_id (string): The unique ID of the review. ●review_id(字符串):评论的唯一ID。 ● product_id (string): The unique Product ID the review pertains to. ●product_id(字符串):审核所属的唯一产品ID。 ● product_parent (string): Random identifier that can be used to aggregate reviews for the same product. ●product_parent(字符串):随机标识符,可用于汇总同一产品的评论。 ● product_title (string): Title of the product. ●product_title(字符串):产品的标题。 ● product_category (string): The major consumer category for the product. ●product_category(字符串):产品的主要消费者类别。 ● star_rating (int): The 1-5 star rating of the review. ●star_rating(int):评论的1-5星评级。 ● helpful_votes (int): Number of helpful votes. ●helpful_votes(int):有用的投票数。 ● total_votes (int): Number of total votes the review received. ●total_votes(int):评论收到的总票数。 ● vine (string): Customers are invited to become Amazon Vine Voices based on the trust that they have earned in the Amazon community for writing accurate and insightful reviews. Amazon provides Amazon Vine members with free copies of products that have been submitted to the program by vendors. Amazon doesn't influence the opinions of Amazon Vine members, nor do they modify or edit reviews. ●vine(字符串):基于客户在撰写准确而有见地的评论方面所获得的信任,邀请客户成为Amazon Vine Voices。亚马逊为Amazon Vine成员提供了供应商已提交给该程序的产品的免费副本。Amazon不会影响Amazon Vine成员的意见,也不会修改或编辑评论。 ● verified_purchase (string): A “Y” indicates Amazon verified that the person writing the review purchased the product at Amazon and didn't receive the product at a deep discount. ●verify_purchase(字符串):“ Y”表示亚马逊已验证撰写评论的人在亚马逊上购买了该产品,并且没有以大幅折扣收到该产品。 ● review_headline (string): The title of the review. ●review_headline(字符串):评论的标题。 ● review_body (string): The review text. ●review_body(字符串):评论文本。 ● review_date (bigint): The date the review was written. ●review_date(bigint):撰写评论的日期。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会编程的七七

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值