Bài toán. Cho xâu ký tự s. Đếm ký tự a và xóa ký tự này trong xâu s, hiển thị xâu s sau khi xóa ký tự a. Ví dụ:
COUTS.INP |
COUTS.OUT |
abaebcda |
3 bebcd |
Code tham khảo:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
freopen("COUTS.INP","r",stdin);
freopen("COUTS.OUT","w",stdout);
string s;
cin>>s;
int dem = 0;
for(int i=0; i<=s.length()-1; i++)
if(s[i] == 'a') dem++;
int i = 0;
int k = 1;
while(i <= s.length()-1) {
if(s[i] == 'a') s.erase(i,1);
else i++;
}
cout << dem << endl;
for(int i=0; i<=s.length()-1; i++)
cout<<s[i];
return 0;
}
Wow, marvelous weblog layout! How long have you ever been running a
blog for? you made blogging look easy. The whole look of your website is excellent,
let alone the content material! You can see similar here sklep online
Hey there! Do you know if they make any plugins to help with Search Engine Optimization? I’m
trying to get my blog to rank for some targeted keywords but I’m not seeing very good success.
If you know of any please share. Many thanks!
You can read similar art here: Sklep internetowy
Hello! Do you know if they make any plugins to assist with
SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing
very good success. If you know of any please share. Appreciate it!
You can read similar text here: Ecommerce