閱讀126 返回首頁    go 阿裏雲 go 技術社區[雲棲]


poj 1658 Eva's Problem

確實是非常水的題,在這裏留個痕跡

AC的代碼:

#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);

	int a[6],i;
	int gap;
	int result;

	while(n--)
	{
		for (i=1;i<=4;i++)
			scanf("%d",&a[i]);

		//等差更容易判斷,如果不是等差就一定是等比
		gap=a[2]-a[1];
		if (gap==a[3]-a[2])
		{
			//是等差數列
			result=a[4]+gap;
		}

		else
		{
			//等比數列
			result=a[4]*a[2]/a[1];
		}

		for(i=1;i<=4;i++)
			printf("%d ",a[i]);

		printf("%d\n",result);
	}
		
	return 0;
}


最後更新:2017-04-03 05:39:19

  上一篇:go httpd: Could not reliably determine the server&#39;s fully qualified domain name
  下一篇:go Access denied for user: &#39;root@localhost&#39; (Using password: YES)