Simply string modification problem. Just input a string variable and change the last character to 4
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
inline int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0' || ch>'9'){if(ch=='-')w-=1;ch=getchar();}
while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
return s*w;
}
int main()
{
string s;
cin>>s;
s[s.length()-1]='4';
cout<<s<<endl;
return 0;
}

这篇文章展示了如何使用C++编程语言,通过cin和cout操作,实现在给定字符串变量的末尾添加特定字符(这里是4),并输出修改后的字符串。

449

被折叠的 条评论
为什么被折叠?



