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. while(n>10){
  13. n =n/10;
  14. first = n%10;
  15.  
  16. }
  17. cout<<(first+last)<<endl;
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5288KB
stdin
3 
1234
124894
242323
stdout
5
5
5