QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84462#5528. Least Annoying Constructive ProblemkkioCompile Error//C++14558b2023-03-06 15:14:542023-03-06 15:15:20

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 15:15:20]
  • 评测
  • [2023-03-06 15:14:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n;
int calc(int x){return (x-1+n)%n+1;}
int main()
{
    scanf("%d",&n);
   	if(n&1)
   	{
   		for(int i=1;i<=n;i++)
   			for(int j=1;j<=(n-1)/2;j++)
			{
				int u=calc(i-j+1),v=calc(i+j);
				if(u>v)swap(u,v);
				printf("%d %d\n",u,v); 
			} 
	}
	else
	{
		n--;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=(n-1)/2;j++)
			{
				int u=calc(i-j+1),v=calc(i+j);
				if(u>v)swap(u,v);
				printf("%d %d\n",u,v); 
			}
			printf("%d %d\n",calc(i,n+1);
		}
	}
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:29:46: error: too many arguments to function ‘int calc(int)’
   29 |                         printf("%d %d\n",calc(i,n+1);
      |                                          ~~~~^~~~~~~
answer.code:4:5: note: declared here
    4 | int calc(int x){return (x-1+n)%n+1;}
      |     ^~~~
answer.code:29:53: error: expected ‘)’ before ‘;’ token
   29 |                         printf("%d %d\n",calc(i,n+1);
      |                               ~                     ^
      |                                                     )
answer.code:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~