05:输出亲朋字符串

05:输出亲朋字符串


总时间限制: 
1000ms 
内存限制: 
65536kB
描述

编写程序,求给定字符串s的亲朋字符串s1。 

亲朋字符串s1定义如下:给定字符串s的第一个字符的ASCII值加第二个字符的ASCII值,得到第一个亲朋字符; 给定字符串s的第二个字符的ASCII值加第三个字符的ASCII值,得到第二个亲朋字符;依此类推,直到给定字符串s的倒数第二个字符。亲朋字符串的最 后一个字符由给定字符串s的最后一个字符ASCII值加s的第一个字符的ASCII值。

输入
输入一行,一个长度大于等于2,小于等于100的字符串。字符串中每个字符的ASCII值不大于63。
输出
输出一行,为变换后的亲朋字符串。输入保证变换后的字符串只有一行。
样例输入
1234
样例输出
cege
应该注意测试用例的输入问题。。。可能包含了空格。。。。
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cstdio>
#include <string.h>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <stdlib.h>
#define MAX_LEN 200
using namespace std;
int a[26] = {0};
char c[105];
int main()
{

    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string str;
    getline(cin, str);  //cin >> str....2分。。测试用例应该包括了空格

    int i;
    for(i = 0; i < str.size() - 1; i++){
        c[i] = str[i] + str[i + 1];
    }
    c[i] = str[0]  + str[str.size() - 1];
    int len = strlen(c);
    //cout << len << endl;
    for(int i = 0; i < len; i++){
        cout << c[i];
    }


    return 0;
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值