Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
uses crt;
var n,s,i,j,l,r: longint;
fi,fo: text;
function tong(n: longint): longint;
var s: longint;
begin
while n>9 do begin
s:=0;
while n>0 do begin
s:=s + n mod 10;
n:=n div 10;
end;
n:=s;
end;
tong:=n;
end;
begin
assign(fi,'TCS.INP'); reset(fi);
assign(fo,'TCS.OUT'); rewrite(fo);
readln(fi,n);
for i:=1 to n do begin
readln(fi,l,r);
s:=0;
for j:=l to r do s:=s+tong(j);
writeln(fo,s);
end;
close(fi);
close(fo);
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll x, y, n, i, tong, tong1;
ll srg(ll x)
{
tong = 0;
if (x <= 9)
{
return x;
}
while (x >= 10)
{
while (x != 0)
{
tong += x % 10;
x /= 10;
}
x = tong;
tong = 0;
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
while (cin >> x >> y)
{
for (i = x; i <= y; i++)
{
tong1 += srg(i);
}
cout << tong1 << endl;
tong1 = 0;
}
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Sự kiện
27
558
8
vt bằng c++ đc k bro
3904
18457
1729
đã update
27
558
8
cho ctlhn luon day:)
15
462
8
full??