求助 不知为何只能输出0
查看原帖
求助 不知为何只能输出0
63362
Zhu_Yi楼主2020/12/30 00:46
#include<stdio.h>
int main(){
	int numbers,i,a,x,m,n,lastresult,result;
	int array[105];
	scanf ("%d",&numbers);
	
	for(i = 0;i < numbers;i++){ /*put numbers into array*/
		scanf("%d",&a);
		array[i]=a;	
	}
	result = 0;
	i--; /*let i stands for the size of array*/
	
	/* x is set to stands for the sum of two numbers*/
		for(x = 0;n < i;){
			for(m = 0;m < i;m++){
				 for(n = 1;n < i;n++){
				 	if(array[n] + array[m] == array[x])
				 	lastresult = result;
				 	result++;
				 	x++;
				 } 
			}
			if(lastresult == result){ 
				x++;
			}	
		}
		printf("%d",result);
		return 0;
}

2020/12/30 00:46
加载中...