poj 1326(水题)

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
    char a[100],b[100],f[2],tmp[100];
    int m,sum;
    sum = 0;
    while(true){
        scanf("%s",tmp);
        if(!strcmp(tmp,"#")){
            break; 
        }
        else if(!strcmp(tmp,"0")){
            printf("%d\n",sum);
            sum = 0;
            continue;
        }
        strcpy(a,tmp);
        scanf("%s%d%s",b,&m,f);
        if(!strcmp(f,"F")){
            sum += m*2;
        }
        else if(!strcmp(f,"B")){
            sum += m+(m+1)/2;
        }
        else if(!strcmp(f,"Y")){
            if(m<=500){
                sum += 500;
            }
            else{
                sum += m;
            } 
        }
    }
    return 0;
}

 

上一篇:【C】8.17写一个函数,实现两个字符串的比较。即自己写一个strcmp函数,函数原型为


下一篇:Day 3 算法笔记之习题集2.7