NOIP蒟蒻的//专栏
一只NOIp的蒟蒻,可能会写以下内容: # 计算机和程序设计 # 题解 # 物理(虽然并没过B卷) # 各种神奇的练习题
文号D907191
1706
0
收藏
编辑文章

洛谷 P1042 [NOIP 2003 普及组] 乒乓球题解

上海市华二陆家嘴分校,栖霞路34号

中文摘要

简单的题解,欢迎交流,前进!

关键词

算法算法竞赛C语言洛谷算法题编程计算机科学noip

题解:

#include<stdlib.h>

#include<stdio.h>

#include<string.h>

#include<math.h>

char input[25*2501],inst=0,me=0,opponent=0;

int count=0;

int main(){

inst=(char)getchar();

while(inst!='E'){

if(inst=='\n'||inst==' '){

inst=(char)getchar();

continue;

}

switch(inst){

case 'W':

input[count]=1;

break;

case 'L':

input[count]=0;

break;

default:

break;

}

inst=(char)getchar();

count++;

}

count--;

if(count==-1){

printf("0:0\n\n0:0");

}

for(int a=0;a<=count;a++){

if (input[a]==1){

me++;

}

if(input[a]==0){

opponent++;

}

if((me>=11||opponent>=11)&&abs(me-opponent)>1){

printf("%d:%d\n",me,opponent);

me=0;

opponent=0;

}

if(a==count){

printf("%d:%d\n",me,opponent);

me=0;

opponent=0;

}

}

printf("\n");

for(int a=0;a<=count;a++){

if (input[a]==1){

me++;

}

if(input[a]==0){

opponent++;

}

if((me>=21||opponent>=21)&&abs(me-opponent)>1){

printf("%d:%d\n",me,opponent);

me=0;

opponent=0;

}

if(a==count){

printf("%d:%d",me,opponent);

me=0;

opponent=0;

}

}

printf("\n");

return 0;

}

0
还没有人评论哦~~

想参与大家的讨论?现在就 登录 或者 注册。

主体信息
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:浙江
 内容统计
2025年
5 篇
2023年
2 篇
2022年
3 篇
2021年
2 篇
2020年
5 篇
2019年
2 篇
ID: {{ user.uid }}
投诉或举报
加载中...
{{ tip }}
请选择违规类型:
{{ reason.type }}

空空如也

加载中...
回复
设为精选取消精选
评学术分
鼓励
编辑
查看历史
通过审核
移动文章
加入收藏取消收藏
退修或删除
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{ format('YYYY/MM/DD HH:mm:ss', toc) }}
回复
加入收藏取消收藏