#include<stdio.h>#include<stdlib.h>#include<string.h>#define MIN -100#define MAX 100inthowMany=0;int*arraySize;int**array;charinput[1000];chartmp[5];intnum;intlen;inti,j,k,l,cnt;intsum,maxSum;intmain(){scanf("%d",&howMany);arraySize=(int*)malloc(sizeof(int)*howMany);array=(int**)malloc(sizeof(int*)*howMany);for(i=0;i<howMany;i++){scanf("%d",&arraySize[i]);if(arraySize[i]<1||(10^5)<arraySize[i]){return-1;}array[i]=(int*)malloc(sizeof(int)*arraySize[i]);while(getchar()!='\n');gets(input);len=strlen(input);k=0;cnt=0;for(j=0;j<len+1;j++){if(input[j]==' '||input[j]=='\0'){tmp[k]='\0';k=0;num=atoi(tmp);if(num<MIN||MAX<num){return-1;}array[i][cnt]=num;cnt++;}else{tmp[k]=input[j];k++;}}}for(i=0;i<howMany;i++){maxSum=0;for(j=0;j<arraySize[i]-1;j++){for(k=j+1;k<arraySize[i];k++){sum=0;for(l=j;l<k+1;l++){sum+=array[i][l];}if(maxSum<sum){maxSum=sum;}}}printf("%d\n",maxSum);}free(arraySize);for(i=0;i<howMany;i++){free(array[i]);}free(array);return0;}
nanosecond
NON ZERO RETURN으로 인한 RTE가 발생하는데,
원인을 모르겠습니다 ㅠㅠ
10년 전