实验三5

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
long fun(long s);
int main()
{
    long s, t;
    printf("Enter a number:");
    while (scanf("%ld", &s) != EOF)
    {
        t = fun(s);
        printf("nuw number is:%ld\n\n", t);
        printf("Enter a number:");
    }
    return 0;
}
long fun(long s)
{
    int j, n,k,i;
    n = 0;
    k = 0;
    while(s>0)
    {
        j = s % 10;
        if (j % 2 != 0)
            n++;
        if (j % 2 == 0)
            j = 0;
        for (i = 1; i <= n-1 ; i++)
            j = j * 10;
        k += j;
        s = s / 10;
    } 
    return k;
}

实验三5

 

上一篇:Kotlin(3)-协程和操作符重载,java技术经理


下一篇:实验三