首页 > 试题广场 >

小乐乐算多少人被请家长

[编程题]小乐乐算多少人被请家长
  • 热度指数:25217 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
小乐乐的班主任想统计一下班级里一共有多少人需要被请家长,三个成绩(语文,数学,外语)平均分低于60的将被请家长,小乐乐想编程帮助班主任算一下有多少同学被叫家长。

    

输入描述:
共n+1行
第一行,输入一个数n,代表小乐乐的班级中有n个同学。
在接下来的n行中每行输入三个整数代表班级中一个同学的三科成绩(语文,数学,外语),用空格分隔。


输出描述:
一行,一个整数,代表班级中需要被请家长的人数。
示例1

输入

3
80 100 90	
40 70 65
20 84 93

输出

1
#include<stdio.h>
int main()
{
	int n = 0;
	int i = 0;
	int count = 0;
	scanf("%d", &n);
	while (i < n)
	{
		int a = 0, b = 0, c = 0;
		scanf("%d%d%d", &a, &b, &c);

		if ( ((a + b + c) / 3) < 60)
		{
			count++;
		}
		i++;
	}
	printf("%d", count);
	return 0;
}

发表于 2021-06-18 05:21:15 回复(0)

                         JavaScript


var n = readline()*1;
var counts = 0;
while(n--){
    var p = readline().split(" ");
    var total = 0;
    for (i = 0;i < 3;i++) {
    total += parseInt(p[i]);
}
    if (total/3 < 60) counts++;
   
}
console.log(parseInt(counts));


发表于 2020-06-23 09:04:11 回复(0)

存在非法的输入
1
60 59 61
0
所以要加上if(n!=0),不然无法通过所有测试用例

import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNextInt())
        {
            int n=sc.nextInt();
            int count=0;
            for(int i=0;i<n;i++)
            {
                int a=sc.nextInt();
                int b=sc.nextInt();
                int c=sc.nextInt();
                int avg=(a+b+c)/3;
                if(avg<60)
                {
                    count++;
                }
            }
            if(n!=0)
            {
                System.out.println(count);
            }             
        }
    }

}
发表于 2020-04-17 14:32:02 回复(1)
#include <stdio.h>
struct stu
{
    int a,b,c;
}st[1005];
int main()
{
    int n;
    scanf("%d",&n);
    int i,cnt=0;
    for(i=0;i<n;i++){
        scanf("%d%d%d",&st[i].a,&st[i].b,&st[i].c);
        if(st[i].a+st[i].b+st[i].c<180) cnt++;
    }
    printf("%d\n",cnt);
}

发表于 2020-04-10 14:04:04 回复(0)
#include<stdio.h>
int main(){
    int n , i_output = 0;
    scanf("%d",&n);
    int Chinese,Math,English;
    while( scanf("%d %d %d",&Chinese,&Math,&English) != EOF )
    {
        if( (Chinese + Math +English) / 3 < 60 ) i_output++;
    }
    printf("%d",i_output);
    return 0;
}

发表于 2022-06-15 10:48:32 回复(0)
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    double a, b, c;
    int cnt = 0;
    while (n)
    {
        cin >> a >> b >> c;
        if ((a + b + c) / 3 < 60) cnt ++ ;
        n -- ;
    }
    cout << cnt << endl;
}

发表于 2022-02-26 14:21:23 回复(0)
#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int count=0;
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c)){
        if((a+b+c)/3<60 && a!=0){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}
测试案例有问题,将问题案例 a = 0 排除即可通过测试
发表于 2021-08-29 00:07:15 回复(0)
#include <stdio.h>

int main() {
    int num,a,b,c,fal=0;
    scanf("%d",&num);
        for(int i=1;i<=num;i++)
        {
                scanf("%d %d %d",&a,&b,&c);

                if((a+b+c)/3<60)
                fal++;
        }

        printf("%d",fal);

    return 0;
}  
发表于 2025-09-16 23:09:25 回复(0)
#include <stdio.h>

int main() 
{
    int n=0;
    scanf("%d\n",&n);
    int i=0;
    int a,b,c;
    int o=0;
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d\n",&a,&b,&c);
        int d=(a+b+c);
        if(d<180)
        {
            o++;
        }
    }
    printf("%d",o);
    return 0;
}

发表于 2024-07-29 20:13:34 回复(0)
a = int(input())
b = 0
for i in range(1,a+1):
    s=list(map(int,input().split()))
    if sum(s)/len(s) < 60:
        b += 1
print(b)

发表于 2024-02-05 10:01:50 回复(0)
#include <stdio.h>

int main() {
    int n,count=0;
    scanf("%d",&n);
    getchar();
    for(int i=0;i<n;i++){
        int a,b,c=0;
        scanf("%d %d %d",&a,&b,&c);
        if((a+b+c)/3<60)
        {
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

发表于 2024-02-03 17:47:40 回复(0)
int main() {
    int i = 0;
    int a, b, c;
    int n = 0;
    int count = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d%d%d", &a, &b, &c);
        if (((a + b + c) / 3) < 60) {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}
n=3时,循环3次让其输入3个数,以此类推。
发表于 2023-09-09 10:59:09 回复(0)
#include <stdio.h>

int main() {
    int n=0;
    scanf("%d\n",&n);
    int a,b,c=0;
    int count =0;
    for(int i=1;i<=n;i++) {
        scanf("%d %d %d\n",&a,&b,&c);
        if((a+b+c)/3 <60) {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

发表于 2022-09-11 16:10:17 回复(0)
n = int(input())
num = 0
for i in range(n):
    s = list(map(int, input().split()))
    if sum(s)/3 < 60:
        num += 1
print(num)

发表于 2021-09-09 10:25:45 回复(0)
#include <stdio.h>

int main() {
    int a = 0;
    int c = 0,m = 0,e = 0;
    int count = 0;
    while(scanf("%d",&a) == 1)
    {
         scanf("%d %d %d",&c,&m,&e);
         int avg = (c + m + e)/3;
         if(avg < 60)
            count++;
    }
    printf("%d\n",count);
    return 0;
}
发表于 2026-04-08 14:45:04 回复(0)
number = int(input())
result = 0
for _ in range(number):
    list_score = list(map(int, input().split()))
    average = sum(list_score) / len(list_score)
    if average < 60:
        result = result + 1
print(result)

发表于 2026-03-24 19:52:32 回复(0)
n = int(input())
d = 0
for i in range(n):
    a,b,c = map(int,input().split())
    if (a+b+c)/3 < 60:
        d += 1
print(d)
发表于 2026-01-21 09:38:23 回复(0)
#include <stdio.h>
int main()
{
    int n  =0;
    int i = 0;
    int yu=0,shu=0,ying=0;
    int x=0;
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d\n",&yu,&shu,&ying);
        if((yu+shu+ying)/3.0<60)
        {
            x=x+1;
        }
    }
    printf("%d\n",x);
    return 0;
}

发表于 2026-01-08 12:32:24 回复(0)
int main() {
    int sum = 0, t;
    cin >> t;
    while(t--) {
        int a, b, c;
        cin >> a >> b >> c;
        if(a + b + c < 180) sum ++;
    }
    cout << sum;
}
发表于 2025-12-06 12:03:47 回复(0)
#include<stdio.h>
int main()
{
    int n;
    int m = 0;
    scanf("%d", &n);
    int a[1000], b[1000], c[1000];
    for (int i = 1; i <= n; i++)
    {
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
        double ave = (a[i] + b[i] + c[i]) / 3;
        if (ave < 60)
        {
            m++;
        }
   }
    printf("%d", m);
    return 0;
}
发表于 2025-12-02 19:46:48 回复(0)

问题信息

上传者:牛客309119号
难度:
115条回答 2948浏览

热门推荐

通过挑战的用户

查看代码
小乐乐算多少人被请家长