题目描述
将C程序代码中的双斜杠注释去掉。 |
输入
输入数据中含有一些符合C++语法的代码行(每行代码不超过200个字符)。需要说明的是,为了方便编程,规定双斜杠注释内容不含有双引号,源程序中没空行。
输出
输出不含有双斜杠注释的C++代码,除了注释代码之外,原语句行格式不变。
样例输入
//====================== // simplest program //====================== #include using namespace std; //---------------------- int main(){ cout<<”hello world!\n”; }//---------------------
样例输出
#include using namespace std; int main(){ cout<<”hello world!\n”; }
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
string s;
while(getline(cin,s))
{
int sign=0;
for(int i=0;i<s.length();i++)
{
if(s[i]=='/'&&s[i+1]=='/') break;
else
{
cout<<s[i];
sign=1;
}
}
if(sign)
cout<<endl;
}
return 0;
}