Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void dziel(int a, int b){
- int w;
- vector<int> v;
- vector<int> tmp;
- cout << a << " / " << b << " = " ;
- cout << a/b << ",";
- if(a>=b){
- a =a%b;
- }
- int r =a;
- tmp.push_back(r);
- bool wystepuje = false;
- int k;
- do{
- r=r*10;
- w= r/b;
- v.push_back(w);
- r=r - b*w;
- //SPRAWDZ CZY r WYSTEPUJE W WEKTORZE v
- for(int i=0; i<tmp.size(); i++){
- if(tmp[i]==r){
- k = i;
- wystepuje = true;
- break;
- }
- }
- tmp.push_back(r);
- }while(!wystepuje and r!=0);
- // if(r!=0){
- // cout << "(";
- // }
- for(int i =0; i< v.size(); i++){
- if (i==k and r!=0){
- cout << "(";
- }
- cout << v[i];
- }
- if(r!=0){
- cout << ")";
- }
- cout << endl;
- }
- int main()
- {
- // int a= 123;
- // int b= 7112;
- for(int a=1000; a<1004; a++)
- for(int b= 1000; b<1004; b++)
- dziel(a,b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement