Advertisement
tamionv

pc

Aug 23rd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. constexpr int maxn = 7;
  5.  
  6. int n, v[maxn], cur[maxn] = {};
  7.  
  8. bool inc(){
  9.     int rest = 1;
  10.     for(int i = n-1; i >= 0; --i){
  11.         cur[i] += rest;
  12.         rest = cur[i] / v[i];
  13.         cur[i] %= v[i]; }
  14.     return rest; }
  15.  
  16. int main(){
  17.     ifstream f("produscartezian2.in");
  18.     ofstream g("produscartezian2.out");
  19.     f >> n;
  20.     for(int i = 0; i < n; ++i) f >> v[i];
  21.  
  22.     do{
  23.         for(int i = 0; i < n; ++i) g << cur[i]+1 << ' ';
  24.         g << '\n';
  25.     } while(!inc());
  26.     return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement