海洋之心


私信TA

用户名:wanggongsheng

访问量:122717

签 名:

等  级
排  名 17
经  验 20534
参赛次数 3
文章发表 163
年  龄 26
在职情况 学生
学  校
专  业 计算机技术

  自我简介:

读研ing,平时不登录dotcpp

解题思路:

注意事项:

参考代码:

#include<iostream>
#include<algorithm>
using namespace std;
char str[1000000];
int main(void)
{
	//freopen("D:\\input1.txt","r",stdin);
	char c,c1,c2;
	while((c1=cin.get())!=EOF)
	{
		if(c1=='/')
		{
			c2=cin.get();
			if(c2=='/')//说明是行注释 
			{
				while((c1=cin.get())!='\n')
				{
					if(c1==EOF) return 0;	
				} 
				cout<<c1;
			}
			else if(c2=='*')//说明是段注释 
			{
				int len=0;
				while(true)
				{
					
					if((c=cin.get())!=EOF) 
					{
						str[++len]=c;
						if(c=='/')
						{
							if(len>=1 && str[len-1]=='*')
								break;
						}
					}
					
				}
			}
			else 
			{
				cout<<c1<<c2;
			}
		}
		else
		{
			cout<<c1;
		}
	}
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区