uva 10070 Camel trading

#include<stdio.h>
#include<string.h>
int main()
{
    int cas,c1,c2,i;
    long long int num1,num2,t,n1[15],n2[15];
    char c;
    scanf("%d",&cas);
    while(cas--)
    {
        c='+';
        num1=1;
        num2=0;
        c1=0;
        c2=-1;
        memset(n1,0,sizeof(n1));
        memset(n2,0,sizeof(n2));
        while(c!='\n')
        {
            scanf("%lld",&t);
            if(c=='+') {n1[c1]+=t;n2[++c2]=t;}
                else{n1[++c1]=t;n2[c2]*=t;}
                scanf("%c",&c);
        }
        for(i=0;i<=c1;i++) num1*=n1[i];
        for(i=0;i<=c2;i++) num2+=n2[i];
        printf("The maximum and minimum are %lld and %lld.\n",num1,num2);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

posted @ 2015-02-13 14:42  xryz  阅读(123)  评论(0编辑  收藏  举报