replaceSpace

#include <iostream> #include <cstring> using namespace std; int main() { char s[]="hello this is a test string"; int count_i=0; for(int i=0;i<strlen(s);i++) { if(s[i]==' ') count_i++; } cout<<count_i<<endl; for(int i=strlen(s);i>=0;i--) { cout<<"COUNT"<<count_i<<endl; if(s[i]==' ') { cout<<"U: "<<i<<" "<<count_i<<endl; s[i+count_i*2]='0'; i--; s[i+count_i*2]='2'; i--; s[i+count_i*2]='%'; count_i--; } else { cout<<"D: "<< i<<" "<<count_i<<" "<<i+count_i*2<<endl; s[i+count_i*2]=s[i]; cout<<count_i<<endl; } } cout<<s<<endl; //cin>>s; return 0; }

2 Responses

man this is C++

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.