Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main() {
- double stiva[100];
- char numar[20];
- unsigned varf = 0;
- printf("Pentru a inchide programul introduceti \n");// sa se opresca una 0 e neutru la adunare
- do { // de aia am ales asa
- printf("st[%u] = ", varf); scanf("%s", &numar);
- if (numar[0] == '0')
- return 0;
- else if (numar[0] == '+' && varf)
- printf("Rezultatul este: %f \n", stiva[varf - 1]);
- else if (numar[0] == ',' && varf)
- --varf;
- else if (numar[0] == '.')
- varf = 0;
- else if (varf)
- stiva[varf] = stiva[varf++ - 1] + atof(numar);
- else if (strchr("+,.", numar[0]))
- printf("Introduceti elemente in stiva!\n");
- else
- stiva[varf++] = atof(numar);
- } while (1);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement