讨论 / 为什么通过,求大神搭救!
520luoyuyi 2016-05-27 19:11:08
点我顶贴 收藏 删除
#include<stdio.h>

#define len 100

int main()

{

int game[len] = {0};

int lose[len] = {0};

char ch = 0;

int a = 0;

int b = 0;

int n = 0;

while (ch!='e')

{

ch = getch();

++n;

if ('w' == ch)

{

game[a] = 1;//win

++a;

}

if ('l' == ch)

{

game[a] = 2;//lose

++a;

}

printf("%c", ch);

if (n%20 == 0)

{

printf("\n");

}

}

printf("\n");

int i;

a = 0;

b = 0;

for (i=1; i<len; ++i)

{

if (game[i-1] == 1)

{

a++;

}

if (game[i-1] == 2)

{

b++;

}

if (a==11 || b==11)

{

printf("%d:%d\n", a, b);

a = b = 0;

if (game[i] == 0)

{

break;

}

}

else if (game[i] == 0)

{

printf("%d:%d\n", a, b);

a = b = 0;

break;

}

}

printf("\n");

for (i=1; i<len; ++i)

{

if (game[i-1] == 1)

{

a++;

}

if (game[i-1] == 2)

{

b++;

}

if (a==11 || b==11)

{

printf("%d:%d\n", a, b);

a = b = 0;

if (game[i] == 0)

{

break;

}

}

else if (game[i] == 0)

{

printf("%d:%d\n", a, b);

a = b = 0;

break;

}

}

return 0;

}

查看更多回复
提交回复