Да се въведат две цели четирицифрени числа и да демонстрира умножение между тях, като се представи като сбор от произведенията на всяка цифра от единия множител с другия множител. Например:
1234 х 1021
-----------
1234
+ 2468
+ 0000
+ 1234
-----------
1259914


#include <cstdlib> #include <iostream> #include <iomanip.h> using namespace std; int main(int argc, char *argv[]) { int a,b; cout << "wuwedi dwe chetirichisleni chisla: "; cin>>a>>b; if (((a<=9999)&&(a>=1000))&&((b<=9999)&&(b>=1000))) { cout<<a<<" x "<<b<<endl; cout<<"__________"<<endl; cout<<setw(11)<<((a%10)*b)<<endl; cout<<"+"<<setw(9)<<((a%100/10)*b)<<endl; cout<<"+"<<setw(8)<<((a%1000/100)*b)<<endl; cout<<"+"<<setw(7)<<((a/1000)*b)<<endl; cout<<"__________"<<endl; cout<<setw(10)<<a*b<<endl; } else cout<<"Newalidni chisla\n"; system("PAUSE"); return EXIT_SUCCESS; }#include <iomanip.h> int x,x1,x2,x3,x4,y; cout<<"Vavedete dve tzeli chisla(max 4-cifreni):"<<endl; cin>>x>>y; //Razdelqme chisloto na cifri x4=x/1000; x3=(x/100)%10; x2=(x/10)%10; x1=x%10; //Podrejdame operaciite cout<<setw(4)<<x<<" x "<<y<<endl; cout<<"-----------"<<endl; cout<<setw(10)<<x1*y<<endl; cout<<"+"<<setw(8)<<x2*y<<endl; cout<<"+"<<setw(7)<<x3*y<<endl; cout<<"+"<<setw(6)<<x4*y<<endl; cout<<"-----------"<<endl; cout<<setw(10)<<x*y<<endl; system("PAUSE"); return 0;#include <cstdlib> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char *argv[]) { int x,y,a,b,c,d; cout<<"Vavedi dve chisla (ot 1000 do 9999): "; cin>>x>>y; if (((x>=1000)&&(x<10000)&&(y>=1000)&&(y<10000))){ a=y/1000; b=y/100%10; c=y/10%10; d=y%10; cout<<x<<"x"<<y<<"="<<x*y<<endl; cout<<endl; cout<<setw(10)<<x*d<<endl; cout<<"+"; cout<<setw(8)<<x*c<<endl; cout<<"+"; cout<<setw(7)<<x*b<<endl; cout<<"+"; cout<<setw(6)<<x*a<<endl; cout<<"----------"<<endl; cout<<setw(10)<<x*y<<endl; } else cout<<"Nevalidni chisla."<<endl; system("pause"); return 0; }