All "Zero" output in tree height program

Basically, the problem is finding the tree height based on the distance to the tree and angle from view to the tree (in other words, the tricky maker made it so that your angle + 90 was what resulted; they gave you 90-180 value, I don't know why, just a variation probably)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  #include <iostream>
#include <math.h>
#define PI 3.14159265
using namespace std;
int main(){
    int a;
    cin>>a;
    int d;
    float b;
    int h;
    for (int i=0;i<a;i++){
        cin>>d;
        cin>>b;
        //Default is radian mode
        int c= ((b-90)*PI)/180;
        h=d* tan(c);
        cout<<round(h)<<" ";
    }
}


Input: 14
86 127.082
56 136.005
32 122.005
101 114.015
72 119.055
57 128.904
107 110.026
25 132.614
85 121.945
59 135.955
49 127.794
46 108.060
41 127.972
128 106.945

Output: 0 0 0 0 0 0 0 0 0 0 0 0 0 0

and no, declaring h as float won't do any good either. Any help?
Last edited on
> int c= ((b-90)*PI)/180;
make `c' a double


Also, use better names for your variables.
thanks
Topic archived. No new replies allowed.