c++中如何显示俩个数的乘积

来源:百度知道 编辑:UC知道 时间:2024/05/26 17:25:32
编写一个程序 读入2个3位数,以下面的形式显示他们乘积
749
×381
————————
749
5992
2247
————————
285369
c++中如何显示俩个数的乘积
悬赏分:10 - 离问题结束还有 14 天 23 小时
编写一个程序 从键盘读入2个3位数,以下面的形式显示他们乘积 譬如以下形式
--------749
------×381
---------------------
--------749
------5992
-----2247
---------------
就是和小学学的一样 一步一步的做乘法 最后加起来
-----285369

#include <iostream>
#include <conio.h>
#include <fstream>
#include <iomanip>
using namespace std;

int main(){
ifstream in("in.txt");//从in.txt读入
int a,b;
in>>a>>b;
in.close();//清空in.txt占用的缓存
cout<<" "<<a<<endl;
cout<<" * "<<b<<endl;
cout<<"------------\n";
cout<<setw(7)<<a*(b%10)<<endl;
cout<<setw(7)<<a*((b/10)%10)<<endl;
cout<<setw(7)<<a*(b/100)<<endl;
cout<<"------------\n";
cout<<setw(7)<<a*b;
getch();
return 1;
}

#include<stdio.h>
int countdig (long x)
{
int m,n;
for(n=0;m!=0;n++)
m=m-x%(1en);
return (n-1);
}
int digit (long x,int dgt)