#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 10
struct datatype {
char sex; /* 男女の性別、男性 M、女性 W */
int expectation; /* 勝ち 1、負け 2、引き分け 0 */
};
void pp(struct datatype*d)
{
int i;
for(i=0; i<N; i++) {
printf("%d %c %d\n",i
,d
[i
].
sex,d
[i
].
expectation); }
}
int sumPrint(struct datatype *d,int n,char c,int x)
{
int i,sum=0;
for(i=0; i<n; i++) {
if((d[i].sex==c)&&(d[i].expectation==x))sum++;
}
return sum;
}
int main()
{
struct datatype d[N];
int i,x;
char buf[N];
printf("debug(0), input(1) = ");
for(i=0; i<N; i++) {
if(x) {
d[i].sex=buf[0];
printf("勝ち(1), 負け(2), 引き分け(0)="); scanf("%d",&d
[i
].
expectation); } else {
d
[i
].
expectation=rand()%3; }
}
pp(d); /* all print for debug */
printf("result :\n男性:勝ち=%d 引き分け=%d 負け=%d\n女性:勝ち=%d 引き分け=%d 負け=%d\n", sumPrint(d,N,'M',1),
sumPrint(d,N,'M',0),
sumPrint(d,N,'M',2),
sumPrint(d,N,'W',1),
sumPrint(d,N,'W',0),
sumPrint(d,N,'W',2)
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KI2RlZmluZSBOIDEwCgpzdHJ1Y3QgIGRhdGF0eXBlIHsKICBjaGFyICBzZXg7ICAgICAgLyog55S35aWz44Gu5oCn5Yil44CB55S35oCnIE3jgIHlpbPmgKcgVyAqLwogIGludCAgZXhwZWN0YXRpb247ICAgLyog5Yud44GhIDHjgIHosqDjgZEgMuOAgeW8leOBjeWIhuOBkSAwICovCn07Cgp2b2lkIHBwKHN0cnVjdCBkYXRhdHlwZSpkKQp7CiAgaW50IGk7CiAgZm9yKGk9MDsgaTxOOyBpKyspIHsKICAgIHByaW50ZigiJWQgJWMgJWRcbiIsaSxkW2ldLnNleCxkW2ldLmV4cGVjdGF0aW9uKTsKICB9Cn0KCmludC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AgICAgICAgIHN1bVByaW50KGQsTiwnVycsMSksCiAgICAgICAgIHN1bVByaW50KGQsTiwnVycsMCksCiAgICAgICAgIHN1bVByaW50KGQsTiwnVycsMikKICAgICAgICApOwoKICByZXR1cm4gMDsKfQ==
debug(0), input(1) = 性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=性別=勝ち(1), 負け(2), 引き分け(0)=0 � -1076079688
1 � -1784951475
2 � -1215613352
3 � 0
4 � 0
5 � 0
6 � 0
7 � 0
8 � 134513760
9 � 134520820
result :
男性:勝ち=0 引き分け=0 負け=0
女性:勝ち=0 引き分け=0 負け=0