[C](0.012)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
struct proposal | |
{ | |
char name[100]; | |
double price; | |
int item; | |
}; | |
typedef struct proposal Proposal; | |
int main() | |
{ | |
int dataset = 1; | |
int n, p; | |
while( scanf( "%d%d", &n, &p ) != EOF && n != 0 && p != 0 ) | |
{ | |
if( dataset > 1 ) | |
printf( "\n" ); | |
getchar(); | |
char recycle[100]; | |
int i, j; | |
for( i = 0 ; i < n ; i++ ) | |
gets(recycle); | |
Proposal list; | |
Proposal best; | |
best.price = 0; | |
best.item = 0; | |
for( i = 0 ; i < p ; i++ ) | |
{ | |
gets(list.name); | |
scanf( "%lf%d", &list.price, &list.item ); | |
getchar(); | |
for( j = 0 ; j < list.item ; j++ ) | |
gets( recycle ); | |
if( list.item > best.item ) | |
best = list; | |
else if( list.item == best.item ) | |
{ | |
if( list.price < best.price ) | |
best = list; | |
} | |
} | |
printf( "RFP #%d\n", dataset ); | |
printf( "%s\n", best.name ); | |
dataset++; | |
} | |
return 0; | |
} |
0 意見:
張貼留言