去掉双斜杠注释

Description

将C程序代码中的双斜杠注释去掉。

Input

输入数据中含有一些符合C++语法的代码行。需要说明的是,为了方便编程,规定双斜杠注释内容不含有双引号,源程序中没空行。

Output

输出不含有双斜杠注释的C++代码,除了注释代码之外,原语句行格式不变。

Sample Input

//======================
// simplest program
//======================
#include
using namespace std;
//----------------------
int main(){
  cout<<”hello world!\n”;
}//---------------------

Sample Output

#include
using namespace std;
int main(){
  cout<<”hello world!\n”;
}

HINT


#include<stdio.h>
#include<string.h>
int main()
{
	char a[1000];
	int t,i;
	while(gets(a))
	{
		t=strlen(a);
		for(i=0;i<t;i++)
		{
			if(a[0]=='/'&&a[1]=='/')//若开始为//则无输出若开始全为空格后面为//则输出换行
				break;
			else
			{
				for(i=0;i<t;i++)
				{
					if(a[i]=='/'&&a[i+1]=='/')
						break;
			    	else
						printf("%c",a[i]);
				}
				printf("\n");
				break;
			}
		}
	}
	return 0;
}

posted @ 2014-11-23 20:23  NYNU_ACM  阅读(528)  评论(0编辑  收藏  举报