首页 > 代码库 > 韩信点兵

韩信点兵

#include <stdio.h>#include <stdlib.h>int main(){    int *a,*b,*c;    int num;    int i;    scanf("%d",&num);    a = (int *)malloc((num+1) * sizeof(int));    b = (int *)malloc((num+1) * sizeof(int));    c = (int *)malloc((num+1) * sizeof(int));    for(i = 1;i <= num;i++){        scanf("%d%d%d",&a[i],&b[i],&c[i]);    }    for(i = 1;i <= num;i++)    {        if((a[i]>=3||a[i]<0)||(b[i]>=5||b[i]<0)||(c[i]>=7||c[i]<0)){            printf("No answer\n");            break;        }        int result;        result = a[i]*2*35 + b[i]*1*21 + c[i]*1*15 - 2*105;        if(result<10||result>100)            printf("No answer");        else            printf("%d",result);        printf("\n");    }    free(a);    free(b);    free(c);}

  

韩信点兵