multiply c

#include <stdio.h>
#include <stdlib.h>

int Multiply(int M, int N)
{
    int Result;

    if (N == 1)
    {
       Result = M;
    }
    else
    {
       Result = M + Multiply(M, N-1);
    }

    return Result;
}

void main()
{
    int NumA;
    int NumB;
    int Product;

    printf("Please enter Number A:");
    scanf("%d", &NumA);
    printf("Please enter Number B:");
    scanf("%d", &NumB);

    Product = Multiply(NumA, NumB);
    printf("%d * %d = %d", NumA, NumB, Product);
}

  

猜你喜欢

转载自www.cnblogs.com/lifelessfaultless/p/9250768.html