// 程式開始
#include "stdio.h"
#include "conio.h"
void main()
{
unsigned int a, b, c, d;
double check;
int i, input_ok = 0;
while (!input_ok) {
printf("請輸入被乘數: "); scanf("%u", &a);
printf("請輸入 乘數: "); scanf("%u", &b);
check = (double)a*b;
if (check <0 || check > 4294967295L) {
printf("乘積必須介於0 ~ 4294967295之間\n\n");
}
else
input_ok = 1;
}
printf("\n%22u\n", a);
printf("x%21u\n", b);
printf("----------------------\n");
for (c=b, i=0; c>0; c=c/10, i++) {
d = c%10;
printf("%*u\n", 22-i, d*a);
}
printf("----------------------\n");
printf("%22u\n", a*b);
_getch();
}
// 程式結束
執行結果:
請輸入被乘數: 1546
請輸入 乘數: 6879
1546
x 6879
----------------------
13914
10822
12368
9276
----------------------
10634934
This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.
留言列表