Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- char a[11];
- cin.get(a,11);
- int bv=0; // beforeVirgula
- int av=0; // afterVirgula
- if (strchr(a,'.'))
- {
- while (a[strlen(a)-1]=='0') a[strlen(a)-1]=0;
- }
- int gasitVirgula=0;
- for(int i=0; i<strlen(a); i++)
- {
- if (a[i]=='.')
- {
- gasitVirgula=1;
- i++;
- }
- if (gasitVirgula==0)
- {
- bv = bv * 10 + (a[i]-'0');
- }
- else
- {
- av = av * 10 + (a[i]-'0');
- }
- }
- cout << av+bv;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement