Vote count:
0
I am getting a segmentation fault error when trying to solve this programming marathon C++ exercise but I can't find the error anywhere:
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void)
{
int m,n,i,di,x,y;
char* let;
cin >> n >> m;
x=0;
y=0;
for (i = 0; i < n; i++)
{
cin >> let >>di;
if ((strcmp(let,"S"))||(strcmp(let,"O"))){
di=(-di);
}
if ((strcmp(let,"N"))||(strcmp(let,"S")))
{
x=+di;
}
if ((strcmp(let,"L"))||(strcmp(let,"O")))
{
y=+di;
}
if ((y*y)+(x*x)>(m*m))
{
cout << "1";
return 0;
}
}
cout << "0";
return 0;
}
asked 1 min ago
C++ segmentation fault on programming exercise
Aucun commentaire:
Enregistrer un commentaire