Va rog mult cum se face problema #3625 de pe pbinfo!
Răspunsuri la întrebare
COROANA !!!
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int cn = n;
int sum = 0;
while (n)
{
sum += (n % 10) * (n % 10);
n /= 10;
}
n = cn;
cout << sum << ' ';
sum = 0;
while (n)
{
if (n % 2 == 1)
sum += n % 10;
n /= 10;
}
n = cn;
cout << sum << ' ';
sum = 0;
while (n)
{
if (n % 10 % 3 == 0)
sum += n % 10;
n /= 10;
}
cout << sum << ' ';
n = cn;
sum = 0;
while (n)
{
if (n % 10 > 5)
sum++;
n /= 10;
}
cout << sum << ' ';
n = cn;
sum = 1;
while (n)
{
if (n % 10 != 0)
sum *= n % 10;
n /= 10;
}
cout << sum << ' ';
sum = 0;
n = cn;
sum = n % 10;
while(n > 9)
n/=10;
cout << sum + n;
return 0;
}
Salut!
Ai rezolvarea in limbaj C++ mai jos
#include <iostream>
using namespace std;
int main()
{
int n, spr = 0, si = 0, s3 = 0, s5 = 0, sp = 1, uc, pc, cn;
cin >> n;
cn = n;
uc = n % 10;
while (n != 0)
{
int c = n % 10;
spr += c*c;
if (c % 2 != 0)
{
si += c;
}
if (c % 3 == 0)
{
s3 += c;
}
if (c > 5)
{
s5++;
}
if (c != 0)
{
sp *= c;
}
n /= 10;
}
while (cn > 9)
{
cn /= 10;
}
pc = cn;
cout << spr << " " << si << " " << s3 << " " << s5 << " " << sp << " " << uc + pc;
return 0;
}