fork download
  1. #include <bits/stdc++.h>
  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. int res = n+last;
  13. if(n>9){
  14. while(n>9){
  15. n =n/10;
  16. first = n%10;
  17.  
  18. }
  19. cout<<(first+last)<<endl;
  20. }else{
  21. cout<<res<<endl;
  22. }
  23.  
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 5288KB
stdin
7
1234
124894
242323
8
6
5
6
stdout
5
5
5
16
12
10
12