标题:乘法竖式
取消只看楼主
万致远醉帥
Rank: 2
等 级:论坛游民
威 望:1
帖 子:88
专家分:35
注 册:2020-3-24
结帖率:100%
 问题点数:0 回复次数:2 
乘法竖式
#include<iostream>
#include<iomanip>
using namespace std;
void yiwei()
{
    int chengshu, beichengshu;
    cout << "一位乘法(请从大到小输入)" << endl;
    cin >> chengshu >> beichengshu;
    system("cls");
    cout << setw(7) << chengshu << endl;
    cout << setw(1) << "×" << setw(5) << beichengshu << endl;
    cout << setw(7) << "-------";
    cout << endl;
    cout<<setw(7)<< beichengshu * chengshu;

   
}
void erwei()
{
    int chengshu, beichengshu;
    cout << "两位乘法(请从大到小输入)" << endl;
    cin >> chengshu >> beichengshu;
    system("cls");
    cout << setw(7) << chengshu << endl;
    cout << setw(1) << "×" << setw(5) << beichengshu << endl;
    cout << setw(7) << "-------";
    cout << endl;
    cout << setw(7) << chengshu * (beichengshu % 10) << endl;
    if (beichengshu/10!=0)
    {
        cout << setw(6) << chengshu * (beichengshu / 10) << endl;
        cout << setw(7) << "-------" << endl;
        cout << setw(7) << beichengshu * chengshu;
    }

   
}
void sanwei()
{
    int chengshu, beichengshu,weishu;
    cout << "3位乘法(请从大到小输入)" << endl;
    cin >> chengshu >> beichengshu;
    cout << "最小几位数?";
    cin >> weishu;
    system("cls");
    switch (weishu)
    {
    case 1:cout << setw(7) << chengshu << endl;
        cout << setw(1) << "×" << setw(5) << beichengshu << endl;
        cout << setw(7) << "-------";
        cout << endl;
        cout << setw(7) << beichengshu * chengshu;
        ; break;
    case 2:cout << setw(7) << chengshu << endl;
        cout << setw(1) << "×" << setw(5) << beichengshu << endl;
        cout << setw(7) << "-------";
        cout << endl;
        cout << setw(7) << chengshu * (beichengshu % 10) << endl;
        cout << setw(7) << chengshu * (beichengshu / 10) << endl;
        cout << "-------";
        cout << endl;
        cout << beichengshu * chengshu;
        break;
    case 4:NULL;cout<<"你大爷的";
    default:cout << setw(7) << chengshu << endl;
        cout << setw(1) << "×" << setw(5) << beichengshu << endl;
        cout << setw(7) << "-------";
        cout << endl;
        cout << setw(7) << chengshu * (beichengshu % 10) << endl;
        cout << setw(7) << chengshu * ((beichengshu % 100)/10) << endl;
        cout << setw(7) << chengshu * (beichengshu / 100) << endl;
        cout << setw(7) << "-------" << endl;
        cout << setw(7) << beichengshu * chengshu;
        break;
    }
}
int main()
{
    short i;
    cout << "最大几位数(1~3)?";
    cin >> i;
    switch (i)
    {
    case 1:yiwei();return 0; break;
    case 2:erwei();return 0; break;
    case 3:sanwei(); return 0; break;
    default:
        break;
    }
    while (true)
    {

    }
}
搜索更多相关主题的帖子: cout cin 乘法 case break 
2020-03-28 13:11
万致远醉帥
Rank: 2
等 级:论坛游民
威 望:1
帖 子:88
专家分:35
注 册:2020-3-24
得分:0 

我们遇到什么困难,也不要怕,微笑着面对他,消除恐惧的最好方法就是面对恐惧。
2020-03-29 08:09
万致远醉帥
Rank: 2
等 级:论坛游民
威 望:1
帖 子:88
专家分:35
注 册:2020-3-24
得分:0 
好像有点不对齐,有人可以改一下吗?





我们遇到什么困难,也不要怕,微笑着面对他,消除恐惧的最好方法就是面对恐惧。
2020-03-29 08:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-500673-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.228905 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved