Choices
--------------------------------------------------------------------------------
Time limit: 1sec. Submitted: 127
Memory limit: 32M Accepted: 63
Source : 计算机学院第二届“光熙杯”程序设计大赛
--------------------------------------------------------------------------------
mostleg is going to attend an exam. All the problems are of the kind "Multiple choices". They all have 4 options and only one of them is right.
In order to get a good mark, he has trained himself for a long time. But he find that he made quite little progress! After the hard work, he only got such an ability that when he saw a problem, he would know the probablity that he could give a right choice. The exam is coming, how to use this ability?
Input
The first line of the input file contains a single integer n (1 <= n <= 300), the number of problems, followed by n lines each containing one real number xi,denoting the probability that he can choose a right choice for this problem.
Output
n lines at all, each display "H%" where H is the percentage chance that he get mark from this problem. Please round H down to the nearest integer before display.
Sample Input
3
1.00
0.65
0.16
Sample Output
100%
65%
28%
#include <stdio.h>
#include <string.h>
int main(void)
{
int a;
scanf("%d", &a);
getchar();
int i = 0, j = 0;
for (i = 0;i < a;i ++)
{
char str[4];
gets(str);
if (str[j] - '0' == 1)
{
printf("100%%\n");
}
else
{
int b = (str[2] - '0') * 10 + (str[3] - '0');
if (b >= 25)
{
printf("%d%%\n", b);
}
else
{
printf("%d%%\n", (100 - b) / 3);
}
}
}
return 0;
}
程序有些乱 程序本身没错 测试结果也对 找了半天找不到那里错了 感觉理解的也不错 大家帮看看