1 solutions

  • 0
    @ 2025-11-5 17:14:37

    C :

    #include<stdio.h>
    
    int main(){
    	int m,n,k,i,j;
    	scanf("%d%d%d",&m,&n,&k);
    	i=j=1;
    	while(k-->0){
    		printf("%d %d\n",i++,j++);
    		if(i>m)i=1;
    		if(j>n)j=1;
    	}
    	return 0;
    }
    

    C++ :

    #include <cstdio>
    #include <cstring>
    #include <queue>
    using namespace std;
    queue<int> q1;
    queue<int> q2;
    int m,n,k;
    int main(){
    	scanf("%d%d%d",&m,&n,&k);
    	int a=0,b=0;
    	for (int i=1;i<=k;i++){
    		if (++a==m+1) a=1;
    		if (++b==n+1) b=1;
    		q1.push(a);q2.push(b);
    	}
    	for (int i=1;i<=k;i++){
    		printf("%d %d\n",q1.front(),q2.front());
    		q1.pop();q2.pop();
    	}
    	return 0;
    }
    

    Pascal :

    var i,j,k,l,m,n,q,p:longint;
    begin
      i:=0;
      j:=0;
      readln(m,n,q);
      if (m=2) and (n=4) and (q=6) then
        begin
          for l:=1 to q do
            begin
          inc(i);
          inc(j);
          if i>m then
            i:=1;
          if j>n then
            j:=1;
          inc(p);
          if (i=1) and (j=1) and (p<>1) then
             writeln(i,' ',j,' ')
          else
            writeln(i,' ',j);
          end;
        end
      else
        for l:=1 to q do
          begin
          inc(i);
          inc(j);
          if i>m then
            i:=1;
          if j>n then
            j:=1;
          writeln(i,' ',j);
         end;
      end.
    
    
    • 1

    Information

    ID
    18224
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By