杭电2061WA 01

#include<stdio.h>
struct mem
{
    char s[50];
    double c;
    double f;
};
int main()
{
   struct mem x[60];
    int n;
    int num,i,flag;//num为课程数量
    scanf("%d",&n);
    while(n--)
    {
        double sum1=0,sum2=0,gpa;
        scanf("%d",&num);
        for(i=0;i<num;i++)
        {
            scanf("%s",x[i].s);
            scanf("%lf",&x[i].c);
            scanf("%lf",&x[i].f);
        }
        for(i=0;i<num;i++)
        {
        	if(x[i].f>=0&&x[i].f<60)
        	{
        		printf("Sorry!\n");
        		flag=0;
        		break;
        	}
        	else
        	{
            sum1+=x[i].c*x[i].f;
            sum2+=x[i].c;
            }

        }
        if(flag)
        {
		gpa=(sum1*1.0)/sum2;
        printf("%.2lf\n",gpa);
        }
        if(n<=1)
        {
        	printf("\n");
        }
    }

}

  找不出错误在哪,待解决

时间: 2024-12-11 12:03:45

杭电2061WA 01的相关文章

杭电 oj2546~0-1背包问题

饭卡 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22962    Accepted Submission(s): 8047 Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法

杭电 1203 I NEED A OFFER!(01背包)

http://acm.hdu.edu.cn/showproblem.php?pid=1203 I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15759    Accepted Submission(s): 6259 Problem Description Speakless很早就想出国,现在他已经考完了

Bone Collector------HDOJ杭电2602(纯01背包问题!!!!!!详解!)

Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone Collector". This man like to collect varies of bones , such as dog's , cow's , also he went to the grave - The bone collector had a big bag with a volu

杭电 2546 饭卡(01背包)

http://acm.hdu.edu.cn/showproblem.php?pid=2546 饭卡 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 11285    Accepted Submission(s): 3880 Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一

01背包基础 (杭电2602)

01背包问题: 有一个体积为V的背包,有n件物品,每件物品的体积,价值分别为w[i],p[i];要从n件物品中选些放入背包中,使背包里物品的总价值最大. 动态方程:c[i][j]=max(c[i-1][j],c[i-1][j-w[i]]+p[i]). 有关动态方程方面的代码: for (int i = 1; i <= n; i++) { for (int j = 1; j <= total_weight; j++) { if (w[i] > j) { c[i][j] = c[i-1][j

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

杭电 2602 Bone Collector

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 27413    Accepted Submission(s): 11154 Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bo

杭电1009-FatMouse&#39; Trade

FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 33703    Accepted Submission(s): 10981 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI