本站遷移

因為我最近租用了網路空間以及網域,
故本站已遷移至新網站~
這邊的資訊已經正在進行搬移的工作~
希望各位可以到新網站去逛XD

New Website:
http://knightzone.org/

搜尋此網誌

2011年3月8日 星期二

[UVa]10141:Request for Proposal

照著題目要求的做即可。

[C](0.012)
#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;
}
view raw UVa10141.c hosted with ❤ by GitHub

0 意見:

張貼留言