Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int main(void)
- {
- using namespace std;
- string sor;
- int i;
- bool noprint = false;
- int noprintfrom;
- while (getline(cin,sor)){
- noprintfrom = 0;
- for (i = 0; i < sor.length(); ++i){
- if (sor[i] == '/' && sor[i+1] == '/'){
- sor.erase(i,sor.length()-i);
- }
- if (sor[i] == '/' && sor[i+1] == '*'){
- noprintfrom = i;
- noprint = true;
- }
- if (sor[i] == '*' && sor[i+1] == '/'){
- noprint = false;
- sor.erase(noprintfrom,noprintfrom - i);
- }
- }
- if (noprint){
- sor.erase(noprintfrom,sor.length()-noprintfrom);
- }
- cout << sor << endl;
- }
- /*//Előző próbálkozás
- char stream;
- char prevstream;
- bool cp_on = false;
- int commentstyle;
- while(cin >> stream){
- //komment kezdete
- if (stream == '/'){
- prevstream = stream;
- cin >> stream;
- if (stream == '/' || stream == '*'){
- cp_on = true;
- if ( stream = '/')
- commentstyle = 1;
- else
- commentstyle = 2;
- }else
- cout << prevstream << stream;
- }
- //komment vége
- if (cp_on){
- if (commentstyle == 1){
- if (stream == '\n' || stream == '\r')
- cp_on = false;
- }else{
- if ( stream == '*'){
- prevstream = stream;
- cin >> stream;
- if ( stream == '/' )
- cp_on = false;
- else
- cout << prevstream;
- }
- }
- }
- if (!cp_on)
- cout << stream;
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement