Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct Penz {
- int euro, cent;
- } Penz;
- Penz beolvas() {
- Penz p;
- scanf("%d %d", &p.euro, &p.cent);
- getchar(); // read enter
- return p;
- }
- Penz osszead(Penz a, Penz b) {
- Penz c;
- c.euro = a.euro + b.euro + ((a.cent + b.cent) / 100);
- c.cent = (a.cent + b.cent) % 100;
- return c;
- }
- Penz kerekit(Penz p) {
- if( p.cent >= 50 )
- p.euro++;
- p.cent = 0;
- return p;
- }
- int main(void) {
- Penz a = beolvas();
- Penz b = kerekit(osszead(a, a));
- printf("%deuro %dc\n", b.euro, b.cent);
- /*Penz a = beolvas();
- Penz b = kerekit(a);
- Penz c = osszead(a, a);
- printf("%deuro %dc\n", a.euro, a.cent);
- printf("%deuro %dc\n", b.euro, b.cent);
- printf("%deuro %dc\n", c.euro, c.cent); */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement