11th Hunan University student Computer Programming Competition "Blue Fox network Cup" B. Hunan Design Competition

Source: Internet
Author: User

11th Hunan University student Computer Programming Competition "Blue Fox network Cup" B. Hunan Design Competition
B-big or small?Time Limit:5000 MSMemory Limit:65535KB64bit IO Format:

Description

Input two real numbers to determine whether the first number is large or not. The format of each number is: [integer]. [decimal part]

For simplicity, both the integer part and the decimal part must be non-null, And the integer part will not have leading 0. However, the decimal part can have 0 at the bottom, so 0.0 and 0.000 are the same size.

Input

The input contains no more than 20 groups of data. Each group of data contains a row with two real numbers (as described above ). Each real number contains no more than 100 characters.

Output

For each group of data, if the first number is large, "Bigger" is output ". If the first number is small, "Smaller" is output ". If the two numbers are the Same, the output is "Same ".

Sample Input

1.0 2.00.00001 0.000000.0 0.000

Sample Output

Case 1: SmallerCase 2: BiggerCase 3: Same

Okay... because I used to brush questions in the team from the past to the next, I was able to see this question first. The question is only in Chinese and there is nothing to explain. The number is a string of 100 characters, so it must be processed with a string. after the decimal point, 0 is automatically added to determine whether the number is the same. Then, the number before the decimal point is larger than the number, the same number of digits starts from the first number, until the result is obtained. The input format for this question has been fixed to "integer part. decimal part", so you don't have to worry about a number without a decimal point. You can simply compare it.

The following code:

#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char a[105],b[105];int max(int a,int b){    return a>b?a:b;}int main(){    int len1,len2;    int i,j;    int k=0;    int d1,d2;    int t;    while(scanf("%s",a)!=EOF)    {        scanf("%s",b);        len1=strlen(a);        len2=strlen(b);        for(i=len1;i<102;i++)        {            a[i]='0';        }        for(i=len2;i<102;i++)        {            b[i]='0';        }        t=0;        k++;        d1=len1;        d2=len2;        cout<<"Case "<<k<<": ";        for(i=0;i<len1;i++)        {           if(a[i]=='.')           {               d1=i;               break;           }        }        for(i=0;i<len2;i++)        {            if(b[i]=='.')            {                d2=i;                break;            }        }        if(d1>d2)        {            cout<<"Bigger"<<endl;            t=2;        }        else if(d1<d2)        {            cout<<"Smaller"<<endl;            t=2;        }        else        {            for(i=0;i<max(len1,len2);i++)            {                if(a[i]>b[i])                {                    t=1;                    break;                }                else if(a[i]<b[i])                {                    t=-1;                    break;                }            }        }        if(t==0)            cout<<"Same"<<endl;        else if(t==1)            cout<<"Bigger"<<endl;        else if(t==-1)            cout<<"Smaller"<<endl;    }    return 0;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.