社区讨论

求助 不知为何只能输出0

P2141[NOIP 2014 普及组] 珠心算测验参与者 1已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@locrzxig
此快照首次捕获于
2023/10/30 18:47
2 年前
此快照最后确认于
2023/11/05 05:31
2 年前
查看原帖
CPP
#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;
}

回复

1 条回复,欢迎继续交流。

正在加载回复...