wu


私信TA

用户名:cncfvc

访问量:215745

签 名:

读研狗没有时间刷题了~~

等  级
排  名 2
经  验 36081
参赛次数 8
文章发表 265
年  龄 25
在职情况 学生
学  校 电子科技大学
专  业 通信工程

  自我简介:

写代码 真好玩 ~

解题思路:

这题的关键在于乘号 以及下划线 你要直接去复制样例里面的
因为这些是特殊符号  你打印不出来
然后注意每个数字的输出位数  要注意位数的对齐
附上两个样例
   5
× 2
━━━
  10
  
  87
×76
━━━
 522
609
━━━
6612        把这些数据复制到编译器里面就能显示正确的格式



参考代码:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	//freopen("data.in.txt","r",stdin);
	//freopen("data.out.txt","w",stdout);
	int a,b;
	while(cin>>a>>b)
	{
	printf("%4d\n",a);
	printf("×%2d\n",b);
	cout<<"━━━"<<endl;
	if(b>=10)
	{
		int b1=b%10;
		if(b1==0)
		printf("  00\n");
		else
		printf("%4d\n",b1*a);
		int b2=b/10;
		printf("%3d\n",b2*a);
		cout<<"━━━"<<endl;
		
	}
	printf("%4d\n",a*b);
	cout<<endl;
    }
	return 0;	
}


 

0.0分

8 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区