Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- int main() {
- double s;
- double drob = 0, counter = 0, dr_counter = 1;
- int dot = 0, save = 0;
- while((s = getchar_unlocked()) != EOF) {
- double num = s - '0';
- if (isdigit(s)) {
- save = 1;
- if (dot == 0) {
- counter *= 7;
- counter += num;
- } else {
- drob *= 7;
- drob += num;
- dr_counter *= 7;
- }
- }
- if (isspace(s) && save == 1) {
- drob = drob / dr_counter;
- if ((drob) == (int)(drob)) {
- printf("%d\n", (int)(counter + drob));
- } else {
- printf("%.10g\n", counter + drob);
- }
- counter = 0, drob = 0, dr_counter = 1;
- dot = 0, save = 0;
- }
- if (s == '.') {
- save = 1;
- dot = 1;
- }
- }
- if (counter + drob != 0) {
- drob = drob / dr_counter;
- if (save == 1) {
- if ((drob) == (int)(drob)) {
- printf("%d\n", (int)(counter + drob));
- } else {
- printf("%.10g\n", counter + drob);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement