Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

getting run time error.I am getting output in my editor.I cant find the error

$
0
0
#include<stdio.h>

main(){ int t,b[100],v; static int q;

scanf("%d",&t);
while(t--){
          int a[100],n,l,p=0,dif=0,max=0;
           scanf("%d",&n);
           l=n;
           for(p=0;p<n;p++) scanf("%d",&a[p]);
           while(n!=1){
               int i=0,j,k,p1=0,p2=0;
               j=l-n;
               k=j+1;
               for(;i<=j;i++)p1+=a[i];


               for(;k<l;k++)p2+=a[k];

               if(p2-p1>0 ) dif=p2-p1;
               else dif=p1-p2;

               if(max<dif) max=dif;
               n--;

                      }
    b[q]=max;
    q++;                          
           }

for(v=0;v<q;v++)printf("%d\n",b[v]);

       }

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>