#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
//产生随机数
srand(time(0));
int a=1+rand()%(10);
int b=1+rand()%(10);
int c=1+rand()%(10);
printf("a=%d,b=%d,c=%d\n",a,b,c);
int count=0,t;
t=a+b+c;
//统计1的个数
if(a==1){
count++;
}
if(b==1){
count++;
}
if(c==1){
count++;
}
//printf("count=%d\n",count);
if(count==0){
printf("The total value is %d\n",t);
}
else if(count==1){
if(t+10<=21)
printf("The total value is %d\n",t+10);
else{
printf("The total value is %d\n",t);
}
}
else if(count==2){
if(t+20<=21)
printf("The total value is %d\n",t+20);
else if(t+10<=21)
printf("The total value is %d\n",t+10);
else {
printf("The total value is %d\n",t);
}
}
else if(count==3){
printf("The total value is 13\n");
}
system("pause");
return 0;
}
01-18
357
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-02