在一行中输入三个非负整数
,分别表示牛牛的作业成绩、小测成绩和期末考试成绩。且保证
均为
的整数倍。
输出一个整数
,表示牛牛的总成绩,满分为
。
100 100 100
100
。
70 80 90
83
。
本题已于下方时间节点更新,请注意题解时效性:
1. 2025-06-03 优化题面文本与格式。
2. 2025-11-20 优化题面文本与格式。
#include <stdio.h>
int main() {
int A = 0, B = 0, C = 0;
scanf("%d %d %d", &A, &B, &C);
printf("%d", (A * 2 + B * 3 + C * 5) / 10);
return 0;
} #include <stdio.h>
int main() {
int A,B,C;
int Condition = 0;
while(!Condition){//循环执行,直到输入正确的值
if(scanf("%d%d%d",&A,&B,&C) != 3){
printf("输入错误,请按照要求输入\n");
while(getchar()!='\n');//清空缓冲区
continue;//跳过并继续循环当前,直到输入正确
}
while(getchar()!='\n');//清空缓冲区;
if(A < 0 || A > 100 || A % 10 != 0 ||
B < 0 || B > 100 || B % 10 != 0 ||
C < 0 || C > 100 || C % 10 != 0){
printf("输入错误!\n");
continue;
}
Condition = 1;//值真,跳出循环执行后续代码。
}
int Score = (A*20)/100+(B*30)/100+(C*50)/100;
printf("%d",Score);
return 0;
} a,b,c=map(int,input().split()) print(int(a*0.2+b*0.3+c*0.5))
#include <stdio.h>
int main() {
int A, B, C;
if (scanf("%d %d %d", &A, &B, &C) != 3) {
return 1;
}
if (0 > A || A > 100 || 0 > B || B > 100 || 0 > C || C > 100 || A % 10 != 0 || B % 10 != 0 || C % 10 != 0) {
return 1;
}
printf("%d", ((2 * A + 3 * B + 5 * C) / 10));
return 0;
} #include <stdio.h>
int main()
{
int A= 0;//作业成绩
int B = 0;//小测成绩
int C = 0;//期末考试成绩
scanf("%d %d %d",&A,&B,&C);
int S = A*0.2+B*0.3+C*0.5;
printf("%d\n",S);
return 0;
} #include <iostream>
#include <cassert>
int calculate_grade(int a, int b, int c){
return a*0.2+b*0.3+c*0.5;
}
int main() {
int a,b,c;
std::cin >> a >> b >> c;
assert(a>=0 && a<=100 && b>=0 && b<=100 && c>=0 && c<=100);
std::cout << calculate_grade(a, b, c) << std::endl;
return 0;
}
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
System.out.printf("%.0f",a*0.2+b*0.3+c*0.5);
}
}
}