Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct distance
- {
- int feet;
- double inches;
- };
- struct distance calc (struct distance a, struct distance b)
- {
- struct distance r;
- r.inches = a.inches + b.inches;
- r.feet = a.feet + b.feet;
- if(r.inches > 11)
- {
- r.inches -= 12;
- r.feet++;
- }
- return r;
- }
- int main ()
- {
- struct distance d1, d2, d3;
- cin >> d1.feet >> d1.inches >> d2.feet >> d2.inches;
- d3 = calc (d1, d2);
- cout << d3.feet << " " << d3.inches;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement