Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- long long TCS(long long n){
- long long tong = 0,a;
- while(n>0){
- a = n % 10;
- tong = tong + a;
- n = n / 10;
- }
- return tong;
- }
- using namespace std;
- int main() {
- int t;
- cin >> t;
- while(t--){
- long long n,i,tong=0;
- cin >> n;
- tong = TCS(n);
- while(tong>=10){
- tong = TCS(tong);
- }
- cout << tong << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement