1-2 输出I Love Programming!

本题要求编写程序,输出一个短句“I Love Programming!”。

输入

本题目没有输入。

输出

在一行中输出短句“I Love Programming!”。(提示:请注意字母的大小写,且最后的感叹号是英文符号,千万不要在中文输入法下输入。)

样例输入1:

样例输出1:

I Love Programming!

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 
        System.out.println("I Love Programming!");
    }

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是过滤注释的C语言代码: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE_LEN 1000 int main(int argc, char *argv[]) { if (argc != 2) { printf("Usage: %s <segment number>\n", argv[0]); exit(1); } int segment_num = atoi(argv[1]); if (segment_num < 1 || segment_num > 5) { printf("Segment number should be between 1 and 5\n"); exit(1); } FILE *fp = fopen("dict.dic", "r"); if (fp == NULL) { printf("Failed to open dict.dic\n"); exit(1); } int end_lines[5]; for (int i = 0; i < 5; i++) { fscanf(fp, "%d", &end_lines[i]); } char line[MAX_LINE_LEN]; int cur_line_num = 0; int in_comment = 0; while (fgets(line, MAX_LINE_LEN, fp)) { cur_line_num++; if (cur_line_num > end_lines[segment_num - 1]) { break; } int len = strlen(line); int i = 0; while (i < len) { if (line[i] == '/' && i + 1 < len) { if (line[i + 1] == '/') { if (!in_comment) { printf("\n"); } break; } else if (line[i + 1] == '*') { in_comment = 1; i++; } } else if (line[i] == '*' && i + 1 < len) { if (line[i + 1] == '/') { in_comment = 0; i++; } } else { if (!in_comment) { printf("%c", line[i]); } } i++; } } fclose(fp); return 0; } ``` 该代码可以读取名为dict.dic的文本文件中的特定代码段,并过滤掉其中的注释。输入为1-5中的一个数字,代表需要读取的代码段编号。对于输入为1,输出结果如下: ```c #include<stdio.h> int main() { int a = 10 , b = 2 , c ; c = a / b ; printf("I love programming C.\n") ; printf("I hope you love it too!\n") ; return 0 ; } ``` 可以看到,所有的注释都被成功地过滤掉了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值