uva 584
来源:互联网 发布:如何当好淘宝客服? 编辑:程序博客网 时间:2024/06/05 02:44
去百度搜索了一下这一题,竟然一个数据都没有,这让我的WA情何以堪!我能想到的所有数据完美运行,但是始终通不过。下附代码,欢迎指正!附调试数据一枚。
/*author chenxingman 2013 2 20 uva_584 */
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
freopen("data.txt","r",stdin);
char store[50]={'\0'};
gets(store);
while(store[0]!='G')
{
int len=strlen(store);
int sum=0,i=0,mark=0,temp=1,l;
//printf("len=%d\n",len);
for(l=len-1;l>=0;l--)
{
if(store[l]!=' ')
break;
}
len=l+1;
//printf("len2=%d\n",len);
while(i<len)
{
if(store[i]=='X')
{sum+=10;i+=2;if(store[i]==' ')i++;}
else {if(store[i+2]=='/')
{sum+=10;i+=4;if(store[i]==' ')i++;}
else
{
sum=sum+store[i]-'0';
i+=2;if(store[i]==' ')i++;
}}
//printf("i=%d sum=%d\n",i,sum);
}
//printf("sum1=%d sum2=",sum);
i=0;
while(mark<=9)
{
if(store[i]=='X') mark++;
else if(temp==1)
{mark++;temp=0;}
else temp++;
if(mark<=9)
{
if(store[i]=='X')
{
if(store[i+2]=='X')
{
if(store[i+4]=='X')
{sum+=20;i+=2;if(store[i]==' ')i++;}
else
{sum=sum+10+store[i+4]-'0';i+=2;if(store[i]==' ')i++;}
}
else if(store[i+4]=='/')
{sum+=10;i+=2;if(store[i]==' ')i++;}
else {sum=sum+store[i+2]-'0'+store[i+4]-'0';i+=2;if(store[i]==' ')i++;}
}
else if(store[i]=='/')
{
if(store[i+2]=='X')
{sum+=10;i+=2;if(store[i]==' ')i++;}
else
{sum+=store[i+2]-'0';i+=2;if(store[i]==' ')i++;}
}
else {i+=2;if(store[i]==' ')i++;}
}
}
printf("%d\n",sum);
gets(store);
}
return 0;
}
/*下附数据:
1 0 1 / 2 2 X 3 3 X 1 / 3 / X 1 2
1 0 1 / 2 2 X 3 3 X 1 / 3 / 1 / X 8 0
1 0 1 / 2 2 X 3 3 X 1 / 3 / 1 / 8 / 9
X X X X X X X X X X X X
1 / 3 / 5 / X X X 3 / 5 / 1 2 8 / 2
X 1 / X 1 / X 1 / X 1 / X 1 / X
1 / X 1 / X 1 / X 1 / X 1 / X 9 / 0
1 / X 1 / X 1 / X 1 / X 1 / X 2 / 0
3 / 4 4 8 / 9 2 7 / X X 2 / 9 / X X X
3 / 4 4 8 / 9 2 7 / X X 2 / 9 / X 4 /
Game Over
*/
- uva 584
- UVa 584
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- hello world!
- 调户口和档案进京的流程
- 不靠广告也盈利:移动应用掘金7大案例剖析
- 如何提升自己的能力
- ios模拟器的方向设置
- uva 584
- ARM程序下载步骤
- adr和ldr的区别
- POJ 2115 C Looooops
- 如何选择自己的嵌入式开发方向
- Use Store Procedure in JPA
- 2012-2013年度总结
- 【线段树】序列操作 operation 四川2010省选 SCOI2010
- Uva 11538-Chess queue象棋中的皇后