#include <iostream>
#include <vector>
#include <cmath>//绝对值函数abs()
using namespace std;
int main()
{
int group;//表示一共几组数据
int n;//表示接下来输入的数据是几元
int num;//组数据里面的数字
cin >> group;
for (int i = 1; i <= group; i++)
{
vector<int> nums;//表示一组数据
vector <int> tempnums;
cin >> n;
for (int j = 1; j <=n ; j++)
{
cin >> num;
nums.push_back(num);
tempnums.push_back(num);
}
for (int k = 0; k < 1000; k++)
{
int total = 0;
for (int j = 0; j< n; j++)
total += nums[j];
if (total == 0)
{
cout << "ZERO\n";
break;
}
for (int j = 0; j < n; j++)
{
if (j==n-1)
tempnums[j] = abs(nums[j] - nums[0]);
else
tempnums[j] = abs(nums[j] - nums[j+1]);
}
for (int j = 0; j < n; j++)
{
nums[j] = tempnums[j];
}
}
int total = 0;
for (int j = 0; j < n; j++)
total += nums[j];
if (total != 0)
{
cout << "Loop\n";
}
}
system("pause");
return 0;
}
运行结果:
运行结果
网友评论