# Triangle , C++ construction, problem with calculating angles

I have a problem with my homework.

1) I should write the function SSS with inputs a, b and c. And I need in output alpha, beta and gamma.

2) I should write the function SWS with inputs a, b, and gamma. And I need in output c, alpha and beta.

Here is my code:

```
#include <iostream>
#include <cmath>
#include <math.h>
#include <cstdio>
using namespace std;
double SSS_alpha(double a, double b, double c){
int bot1 = -2*b*c;
if(bot1==0.0){
return 0.0;
}
double alpha = acos((a*a-b*b-c*c)/bot1);
const double rad = 0.5729577951308232088;
return alpha*rad;
}
double SSS_beta(double a, double b, double c){
double bot2 = -2*c*a;
if(bot2==0.0){
return 0.0;
}
double beta = acos((b*b-c*c-a*a)/bot2);
const double rad = 0.5729577951308232088;
return beta*rad;
}
double SSS_gamma(double a, double b, double c){
double bot3 = -2*b*a;
if(bot3==0.0){
return 0.0;
}
double gamma = acos((c*c-a*a-b*b)/bot3);
const double rad = 0.5729577951308232088;
return gamma*rad;
}
double WSW_seite_c(double a, double b, double gamma){
double c_1 = (a*a+b*b-2*a*b*cos(gamma));
double c = sqrt(c_1);
return c;
}
int main(){
cout << SSS_alpha(5.0, 7.0, 8.0)<<endl;
cout <<SSS_beta(5.0, 7.0, 8.0)<<endl;
cout <<SSS_gamma(5,7,8)<<endl;
cout <<"Seite c: "<<WSW_seite_c(5, 7, 0.81)<<endl;
}
```

I can in one function only 1 return. And I have a lot of functions for task 1:for alpha, for beta, for gamma. And I don't know how can I write it in one function. I wrote for task 2 only one function for finding c.

I am new in C++. I would be happy, if you can help me.:)

### 1 Answer

A `struct`

will be the simplest way of doing what you want. You can also create a class, but it might be an overkill solution for a homework.

a struct declaration goes like this :

```
struct containerName
{
int val_a;
double val_b;
//and so on : you put what ever you need
}
```

The struct then basically becomes a type you can use pretty much like `int`

, `double`

, `bool`

etc.

Here's a nice reading on `struct`

and how to use it

You can group in a

`struct`

some values. Then pass a reference to that`struct`

. Inside the function you can change those struct-values.