HRBUST-1130 Hrbust 集训队

 很久以前做的题了,今天翻自己整理的做题心得,看到了这个题,就来写一下

(代码先贴这儿了,有空补思路=.=)

AC代码:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define PI acos(-1)

int main()
{
    char stats[100];
    int grade,num;
    int i,j;
    while(scanf("%s",stats)!=EOF)
    {
        getchar();
        grade = 0;
        for(i = 0; i < strlen(stats); i++)
        {
            num = 0;
            if(stats[i] == 'T')
            {
                if(stats[i+1] == 'T')
                    grade++;
                if(i == strlen(stats) - 1)
                    grade++;
                else if(stats[i+1] != 'T')
                {
                    for(j = i + 1; j < strlen(stats); j++)
                    {
                        if(stats[j] == 'T')
                        {
                            i = j -1;
                            break;
                        }
                        num = num * 10 + stats[j] - '0';
                    }
                    grade += num *2;

                }
            }
        }
        printf("%d\n",grade);
    }
    return 0;
}

写于自习间(明天就不允许带电脑了TAT)

猜你喜欢

转载自blog.csdn.net/qq_43005180/article/details/83063294