### pnsrp's blog

By pnsrp, 9 years ago, Hi, everyone. In the contest, the judge said i got wrong answer in test case 6. I waited for the contest to be over and I checked the test case, then, i tried to run it with that test case i failed, i got the correct answer in my computer. Why is my solution is wrong for the judge? My code is here. http://pastebin.com/GJWP7a5t By pnsrp, 9 years ago, hi anybody can help me, in the second iteration, i'm getting this value, -2.77556e-17 instead of zero, sorry for disturbing you guys, i'm really lost. Pls help me. My code is like this. I'm coding an neutron which learns and  gate.
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
int i, j;
double dataIn;
freopen( "input.txt", "r", stdin);
for( i=0; i<4; i++ ){
for( j=0; j<3; j++ ){
cin >> dataIn[i][j];
}
}
double weight = { 0.3, -0.1 };
double error;
double threshold = 0.2;
int output;
double alpha = 0.1;
int epoch = 0;
int t = 2; //debugging: trying running just two iterations
while(t--){
for( i=0; i<4; i++ ){
double sum = (dataIn[i] * weight) + (dataIn[i] * weight) - threshold;
cout << dataIn[i] * weight << " " << dataIn[i] * weight << " " << threshold << endl;
cout << sum << endl;
sum >= 0 ? output = 1 : output = 0;
cout << output << endl;
if( output != dataIn[i] ){
error[i] = dataIn[i] - output;
weight = weight + (alpha*error[i]*dataIn[i]);
weight = weight + (alpha*error[i]*dataIn[i]);
}
else error[i] = 0;
//    cout << weight << " " << weight << endl;

}
cout << endl;
epoch++;
if( error == 0 && error == 0 && error == 0 && error == 0 ) break;
else continue;
}
cout << epoch << endl;
return 0;
} By pnsrp, 10 years ago, Anybody can help me, I got runtime error for the this problem, 1B - spread sheet, it works fine in my computer.

#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<stack>

using namespace std;

char convert(int cno){
return cno - 1 + 'A';
}

int convert2n (char ch){
return ch - 'A' + 1;
}

int main()
{
int n, index, cno, total=0, multiplicand=1;
string input, row, col;
stack<char>ch_stack;
cin >> n;
while(n--){
cin >> input;
if(input=='R' && (input>=48 && input<=57)){
for(int i=2; i<input.size(); i++){
if(input[i]=='C') {index=i; break;}
}
row = input.substr(1,index-1);
col = input.substr(index+1);
cno = atoi(col.c_str());
if(cno<=26){
cout << convert(cno) << row << endl;
}
else {
while(cno>26){
ch_stack.push(convert(cno%26));
cno /= 26;
}
ch_stack.push(convert(cno));
while (!ch_stack.empty()){
cout << ch_stack.top();
ch_stack.pop();
}
cout << row << endl;
}
}
else {
for(int i=1; i<input.size(); i++){
if(input[i]>=48 && input[i]<=57) {index=i; break;}
}
row = input.substr(index);
col = input.substr(0, index);
for(int i=col.size()-1; i>=0; i--){
char ch = col[i];
total += convert2n(ch)*multiplicand;
multiplicand *= 26;
}
cout << "R" << row << "C" << total << endl;
multiplicand = 1;
total = 0;
}

}
//system("pause");
return 0;
}
I did it in a stupid way, but i wanted to know why i got that runtime error, Please help me.
Thank you. 1b,