阅读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)