I am supposed to get the output as 2 0 3 for the sample test cases, but i am getting 3 1 3 . I have used the correct formula to calculate the strike rate but stil i am not getting correct. Don’t want other solution, just want to know went wrong with this code.
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t; cin>>t;
while(t–){
int cnt=0, r=0;//r–>runs,
int n;
cin>>n;
//input array.
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
r+=a[i];
int sr=(float(r/(i+1)))*100;
if(sr==100) cnt++;
}
cout<<cnt<<endl;
}
}