码迷,mamicode.com
首页 > 其他好文 > 详细

vijos p1217 乒乓球

时间:2017-10-12 10:10:14      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:line   main   property   output   macro   ios   turn   bar   p12   

注意数组越界。
#include<iostream> #include<cmath> using namespace std; char letter[10001]; void Output(int cap,int type) { int w = 0, l = 0; for (int i = 0; i < cap; i++) { if (letter[i] == ‘W‘) w++; if (letter[i] == ‘L‘) l++; if (((w == type||l==type)&&(abs(l-w)>=2))||((w>type||l>type)&&(abs(l-w)==2)) ){ cout << w << ‘:‘ << l; w = 0, l = 0; cout << endl; } } cout << w << ‘:‘ << l; } int main() { int i = 0; while ((letter[i] = getchar()) != EOF) { if (letter[i] == ‘E‘) break; i++; } Output(i, 11); cout << endl<<endl; Output(i, 21); return 0; }

vijos p1217 乒乓球

标签:line   main   property   output   macro   ios   turn   bar   p12   

原文地址:http://www.cnblogs.com/ruoh3kou/p/7654466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!