重點內容
#include <stdio.h>
int main()
{
int t;
scanf ("%d", &t);
long long a[t], b[t], c[t];
for (int i=0; i < t; i++){
scanf ("%lld %lld", &a[i], &b[i]);
c[i] = (a[i] * b[i]) % 10000;
}
for (int i = 0; i < t; i++){
if (c[i]>999)
printf("%lld", c[i]);
else if (c[i]>99)
printf ("%04lld", c[i]);
else if (c[i]>9)
printf ("%04lld", c[i]);
else printf ("%04lld", c[i]);
printf ("\n");
}
return 0;
}
學到的知識
%d 輸出短整型
%2d 輸出場寬爲2,不足補空格
%03d %.3d 輸出場寬爲3,不足補0
擴充知識
%f 輸出小數
%.2f 輸出保留兩位小數