my coefficients of average of the SBC are:
AV[0] = 0;
AV[1] = 5506 / 2100;
AV[2] = 216824 / 10500;
AV[3] = 299414 / 10500;
AV[4] = 678002 / 10500;
AV[5] = 271884 / 3500;
AV[6] = 461178 / 3500;
AV[7] = 1576244 / 10500;
But i have WA
![:(](./images/smilies/icon_frown.gif)
Moderator: Board moderators
Code: Select all
#include <iostream>
#include <string>
using namespace std;
double p[]={12.53,1.42,4.68,5.86,13.68,0.69,1.01,0.70,6.25,0.44,0.00,4.97,3.15,6.71,8.68,2.51,0.88,6.87,7.98,4.63,3.93,0.90,0.02,0.22,0.90,0.52};
double sbc(string w)
{
int k;
double su=0;
for (k=0;k<w.length();k++)
{
su += k*p[(int(w[k])-97)];
}
return su;
}
int main()
{
int i,l,k,m,n;
double j[100];
string str[100];
cin >> i ;
for (l=0;l<i;l++)
{
cin >> str[l];
j[l]=sbc(str[l]);
}
for (l=0;l<i;l++)
{
m = str[l].length();
n=0;
double sum=0,av = 0;
for (k=0;k<i;k++)
{
if (str[k].length() == m)
{
n +=1;
sum += sbc(str[k]);
}
}
av = sum / n;
if (sbc(str[l]) < av) cout << "below"<< endl;
else cout << "above or equal" << endl;
}
return 0;
}
Emilio wrotebefore i sent this code to online judge i had test it with dev4.9.9.2 and visual studio C++ 6.0 and worked well
but i dont know why it says it has "runtime error!" :
Yes this is the reason of getting u run time. But I think if u increase the array size u will get wrong answer because u missunderstood the problem.Why is your array size 100? It could be the reason
Mushfiqur Rahman wroteWhy is your array size 100? It could be the reason![]()
oh, thanksBut I think if u increase the array size u will get wrong answer because u missunderstood the problem...