1/ 比较函数

#include <stdio.h>

compare(int a,int b)
{
    return a>b?a:b;
}

main()
{
    int a,b,c;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(a==b)
        {
            printf("A=B\n");
        }
        else
        {
            c=compare(a,b);
            if(c==a)
            {
                printf("A>B\n");
            }
            else
            {
                printf("A<B\n");
            }
        }
    }
}





2/
#include <stdio.h>

main()
{
    int a;
    while(scanf("%d",&a)!=EOF)
    {
        if(a>0&&(a%2==0))
        {
            if(a>10)
            {
                printf("This is a more than 10 even\n");
            }
            else
            {
                printf("This is an even number\n");
            }
        }
        else if(a==0)
        {
            printf("This is an even number and it is zero\n");
        }
        else
        {
            printf("This isn't an even number\n");
        }
    }
}


3/
#include <stdio.h>

int main()
{
    int sum,i,a,n;
    scanf("%d%d",&a,&n);
    sum=n*a;
    for(i=1;i<n;i++)
    {
        a=a*10;
        sum+=(n-i)*a;
    }
    printf("%d",sum);
    return 0;
}


4/
#include<stdio.h>

int main()
{
    int n,i;
    scanf("%d",&n);
    printf("%d=",n);
    for(i=2;i<=n;i++)
    {
        while(n!=i)
        {
            if(n%i==0)
            {
                printf("%d*",i);
                n=n/i;
            }
            else
            break;
        }
    }
    printf("%d",n);
    return 0;
}


5/数字根


#include <stdio.h>

int main()
{
    int i=0,j,all[100],all_n[100],a;
    int k,t;
    for(i=0;i<100;i++)
    {
        scanf("%d",&a);
        if(a==0)
        {
            break;
        }
        else
        {
            all[i]=a;
        }
    }
    for(j=0;j<i;j++)
    {
        t=all[j];
        do
        {
            k=t;
            t=0;
            while(k)
            {
                t+=k%10;
                k/=10;
            }
        }while(t/10!=0);
        all_n[j]=t;
    }
    for(i=0;i<j;i++)
    {
        printf("%d\n",all_n[i]);
    }
        return 0;
}