KiKi想知道他的考试成绩是否完美,请帮他判断。从键盘输入一个整数表示的成绩,编程判断成绩是否在90~100之间,如果是则输出“Perfect”。
import java.util.Scanner; /** * @Title: 完美成绩 * @Remark: KiKi想知道他的考试成绩是否完美,请帮他判断。从键盘输入一个整数表示的成绩,编程判断成绩是否在90~100之间,如果是则输出“Perfect”。 * @Author: ijunfu * @Version: 1.0.0 * @Date: 2022-03-19 */ public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNextInt()) { int score = in.nextInt(); if(score >= 90 && score <= 100 ) System.out.println("Perfect"); } } }
#include<stdio.h> #define PERFECT "Perfect" int main(void){ int score; while(scanf("%d", &score) != EOF){ getchar(); if(score >= 0 && score <= 100){ if(score >= 90 && score <= 100) printf(PERFECT); } else printf("分数输入错误!!"); } return 0; }稍微思考下就会想的比较全面,基本上算是语法题,if-else
while 1: try: score = int(input()) if score >=90 and score <=100: print("Perfect") else: continue except EOFError: break
# include<bits/stdc++.h> using namespace std; int main() { int score; while(cin >> score) { if(score >=90 && score <=100) cout << "Perfect\n"; } return 0; }