Varianta 55 / Subiectul 2 / Problema 5 |
#include<iostream.h> #include<string.h> #include<stdlib.h> void main() { char s[10]; cin>>s; char *p=strchr(s,'.'); strncpy(s,s,p-s); long a=atol(s); long b=atol(p+1); while(b%10==0) b=b/10; cout<<a+b; } sau #include<iostream.h> void main() { int a=0, b=0,i; char s[10]; cin>>s; i=0; while(s[i]!='.') { a=a*10+(s[i]-'0'); i++; } i++; while(s[i]!='\0') { b=b*10+(s[i]-'0'); i++; } while(b%10==0) b=b/10; cout<<a+b; } |