Please help me with this problem:-
Suppose a number N is 189. The sum of digits S is 1+8+9=18. Since S is not a unit digit number ( i.e. S>=10) So for next loop** S = 1+8=9**. So the solution that mohit comes up with will be 9.
Input Format
First line contain T testcases. Each T lines contain a number N.
Constraints
(1<=T<=10^5) (1<=N<=10^9)
Output Format
For Each T line print a single number S (1<=S<=9).
Sample Input 0
3
189
15
200
Sample Output 0
9
6
2
Though i have tried to code it but it seems to not work with other testcases.
Here is my code:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int ad(int long long);
int bh(int long long);
int main() {
int long long a[100000],b,c,sum,e,limit;
cin>>limit;
for(int i=1;i<=limit;i++)
{cin>>a[i];}
for(int i=1;i<=limit;i++)
{
sum=0;
Suppose a number N is 189. The sum of digits S is 1+8+9=18. Since S is not a unit digit number ( i.e. S>=10) So for next loop** S = 1+8=9**. So the solution that mohit comes up with will be 9.
First line contain T testcases. Each T lines contain a number N.
Can somebody please help me?
I don't know the problem you are having yet.
What does the word "mohit" mean?
"mohit" is a name in the problem. i am not able to get through with other testcases. that is my code is yunable to run with some integers. i wanted to check if my code is right.