Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long  n,m,k,k1,cnt,t;
  4. bool odd;
  5. int main()
  6. {
  7.     cin>>n>>m>>k;
  8.     k1=(n*m)/k;
  9.     if((n*m)%k)
  10.     {
  11.         odd=1;
  12.     }
  13.     cout<<k1<<' ';
  14.     for(int i=0; i<n; i++)
  15.     {
  16.         if(!i%2)
  17.         {
  18.             for(int j=0; j<=m-1; j++)
  19.             {
  20.                 cout<<i+1<<' '<<j+1<<' ';
  21.                 cnt++;
  22.                 if(cnt==k1)
  23.                 {
  24.                     t++;
  25.                     cnt=0;
  26.                     if(odd)
  27.                     {
  28.                         if(t==k-1)
  29.                         {
  30.                             k1++;
  31.                         }
  32.  
  33.                     }
  34.                     if(t<k)
  35.                     {
  36.  
  37.                         cout<<endl;
  38.                         cout<<k1<<' ';
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.         else
  44.         {
  45.             for(int j=m-1; j>=0; j--)
  46.             {
  47.                 cout<<i+1<<' '<<j+1<<' ';
  48.                 cnt++;
  49.                 if(cnt==k1)
  50.                 {
  51.                     t++;
  52.                     cnt=0;
  53.                     if(odd)
  54.                     {
  55.                         if(t==k-1)
  56.                         {
  57.                             k1++;
  58.                         }
  59.  
  60.                     }
  61.                     if(t<k)
  62.                     {
  63.  
  64.                         cout<<endl;
  65.                         cout<<k1<<' ';
  66.                     }
  67.                 }
  68.             }
  69.         }
  70.     }
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement