A - Move Right /247

    题目链接    

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100 points

Problem Statement

There are 4 squares lined up horizontally.

You are given a string S of length 4 consisting of 0 and 1.
If the i-th character of S is 1, there is a person in the ii-th square from the left;
if the i-th character of S is 0, there is no person in the ii-th square from the left.

Now, everyone will move to the next square to the right simultaneously. By this move, the person who was originally in the rightmost square will disappear.

Determine if there will be a person in each square after the move. Print the result as a string in the same format as SS. (See also Sample Input / Output for clarity.)

Constraints

  • S is a string of length 4 consisting of 0 and 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print a string of length 4 such that the ii-th character is 1 if there will be a person in the i-th square from the left after the move, and 0 otherwise.


Sample Input 1 Copy

Copy

1011

Sample Output 1 Copy

Copy

0101

After the move, the person who was originally in the 1-st square will move to the 2-nd square,
the person in the 3-rd square to the 4-th square,
and the person in the 4-th square will disappear.


Sample Input 2 Copy

Copy

0000

Sample Output 2 Copy

Copy

0000

Sample Input 3 Copy

Copy

1111

Sample Output 3 Copy

Copy

0111

翻译:给你一个01序列,0表示没有人,1表示有人,问你将这个01序列向后移动一个位置后的序列是什么

思路:第1个位置肯定是0,因为是新出现的位置,第二个位置是原来的第一个位置,本质应该是一个数组循环右移的问题,那么直接开一个新的字符串去复制一下就好了

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string res = "0";
    for (int i = 0; i < 3; i ++ )   res += s[i];
    cout << res << endl;
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值