2021年3月22日星期一

why my break statement inside IF is not working?

This is my code I am trying to print the subarray of the given sum why break statement inside if condition is not working, help me with solutions..

#include<stdio.h>  int main(){      int n,s,i,temp=0;      scanf("%d",&n);      scanf("%d",&s);      int a[n];      for(i=0;i<n;i++){          scanf("%d",&a[i]);      }      for(i=0;i<n;i++){          for(int j=i;j<n;j++){         temp=temp+a[j];         if(temp==s){           printf("%d %d\n",i+1,j+1);           break;         }      }      temp=0;      }      return 0;  }  
https://stackoverflow.com/questions/66757550/why-my-break-statement-inside-if-is-not-working March 23, 2021 at 01:05PM

没有评论:

发表评论