帮忙优化一下程序
题目:第一行是数列的数目t(0 <= t <= 20)。以下每行均包含四个整数,表示数列的前四项。约定数列的前五项均为不大于10^5的自然数,等比数列的比值也是自然数。对输入的每个数列,输出它的前五项。源程序:
#include"stdio.h"
int enter_num();
int judge(int i[]);
int main()
{
int progression_num;
int i[4];
int k;
int count=0;
progression_num=enter_num();
// printf("%d ",progression_num);
while(count<PROGRESSION_NUM)
{
printf("input the first four number(only four):");
for(k=0;k<4;k++)
scanf("%d",&i[k]);
judge(i);
count++;
}
return 0;
}
//enter_num define
int enter_num()
{
int progression_num;
printf("Enter the num of progression (attention:0<=num<=20) : ");
scanf("%d",&progression_num);
if(progression_num<0||progression_num>20)
{
printf("error,please input again!\n");
enter_num();
}
return progression_num;
}
//judge define
int judge(int i[])
{
if((i[3]-i[2])==(i[2]-i[1])&&(i[2]-i[1])==(i[1]-i[0]))
{
printf("this progression is arithmetic progression:");
printf("%d %d %d %d %d\n",i[0],i[1],i[2],i[3],i[3]+(i[3]-i[2]));
}
else if((i[3]/i[2])==(i[2]/i[1])&&(i[2]/i[1])==(i[1]/i[0])&&(i[3]%i[2]==0)) {
printf("this progression is geometric progression:");
printf("%d %d %d %d %d\n",i[0],i[1],i[2],i[3],i[3]*(i[3]/i[2]));
}
else
printf("error,this progreesion is not arithmetic or geometric\n");
}