实验4-15:乘运算列竖式 从键盘读入2个两位以内的整数,进行乘法运算并以竖式输出。(注意,乘号以小写字母x代替,横线以7个减号代替),注意数据的输出格式。 例如:
8 28
28
x 8
-------
224
|
#include<stdio.h>
int main()
{
int a, b, c;
scanf("%d%d",&a,&b);
int unit = (a%10)*b;
int tens = (a/10)*b;
printf("%6d\nx%5d\n-------\n%6d\n",b,a,unit);
if(tens!=0)
{
printf("+%4d\n-------\n%6d",tens,a*b);
}
return 0;
}
得分10.00 最后一次提交时间:2023-04-01 10:19:45 成功编译,但有警告信息. Main.c: In function 'main': Main.c:4:15: warning: unused variable 'c' [-Wunused-variable] int a, b, c; ^ 共有测试数据:2 平均占用内存:1.211K 平均CPU时间:0.00282S 平均墙钟时间:0.00282S
详细
|