code.club

標題: 表達出二個數的直式相乘寫法 [打印本頁]

作者: enter    時間: 2015-8-21 02:16
標題: 表達出二個數的直式相乘寫法
#include <stdio.h>
#include <Stdlib.h>

int main(void){
int x,y;       
printf("enter 2 numbers:\n");
scanf("%d %d",&x,&y);
printf("%6d\n",x);
printf("X%5d\n",y);
printf("----------\n");
printf("%6d\n",x*(y%10));
printf("%5d\n",x*((y/10)%10));
printf("%4d\n",x*(y/100));
printf("----------\n");
printf("%6d\n",x*(y%10)+x*((y/10)%10)*10+x*(y/100)*100);

        return 0;
}




歡迎光臨 code.club (https://code.club/) Powered by Discuz! X3.2