1086: 去掉双斜杠注释

来源:互联网 发布:yaml nginx 编辑:程序博客网 时间:2024/05/29 15:43

题目

Description

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

Input

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

Output

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

Sample Input//======================// simplest program//======================#includeusing namespace std;//----------------------int main(){  cout<<”hello world!\n”;}//---------------------Sample Output#includeusing namespace std;int main(){  cout<<”hello world!\n”;}

代码块

import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner cn = new Scanner(System.in);        while (cn.hasNext()) {            String s = cn.nextLine();            int m = s.indexOf("/");            if (m == 0) {            } else if (m > 0) {                for (int i = 0; i < m; i++) {                    System.out.print(s.charAt(i));                }                System.out.println();            } else if (m < 0) {                System.out.println(s);            }        }        cn.close();    }}
0 0
原创粉丝点击