fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin>> t;
  7. while(t--){
  8. int n;
  9. cin>> n;
  10. int last = n%10;
  11. int first = 0;
  12. if(n<9){
  13. while(n>9){
  14. n = n/10;
  15. first = n%10;
  16. }
  17. cout<<(first+last)<<endl;
  18. }else{
  19. cout<<(n+last)<<endl;
  20. }
  21.  
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5284KB
stdin
3 
1234
124894
242323
stdout
1238
124898
242326