/* 2.cpp .2. 编写一个函数,
把字符串中所有的字符都前移一个位置,
而串中的第一个字符移到最后。并编写主程序进行测试。*/
#include <iostream>
#include <string.h>
#include <cstring>
using namespace std;
int movespace(int i,int n)
{
if (i == (n - 1))
return 0;
else
return i + 1;
}
int main()
{
string s;
cin >> s;
int n = s.length();
const char* str = s.c_str();
for (int i = 0; i < n; i++)
{
cout << str[movespace(i,n)];
}
return 0;
}
//将数组str作为函数参数
void fun(char* str)
{
???
}