Poj Solution 2810

http://poj.org/problem?id=2810

#include <stdio.h>
#include <memory.h>
#include <vector>
#include <string>
using namespace std;

vector<string> v;
int main( ) {
    double a, b;
    int i, j;
    char w[1000], unit[1000];
    
    while( 1 ) {
        scanf( "%lf %s %lf %1s", &a, unit, &b, w );
        
        gets( w+1 );

        if( a < 0 )
            break;
        
        if( a >= b*0.01 ) {
            for( i=0; w[i]; i++ )
                printf( "%c", w[i] );
            printf( " %.1lf %s %.0lf%%n", a, unit, a/b*100 );
        }
        else
            v.push_back( string(w) );
    }

    printf( "Provides no significant amount of:n" );
    for( i=0; i<v.size( ); i++ ) {
        for( j=0; j<v[i].size(); j++ )
            printf( "%c", v[i][j] );
        printf( "n" );
    }

    return 0;
}


											
This entry was posted in poj. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *