View difference between Paste ID: Zrf952qq and y0xrBqmZ
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <string>
3
4
using namespace std;
5
6
7
void ArmStrongNumberCheck(int input)
8
{
9
	string tempStr = to_string(input);
10
	int digits = tempStr.size();
11
	digits;
12
	double sum = 0;
13
	for(int i =0; i< digits;i++)
14
	{
15
		int tempNumber = tempStr.at(i) - 48;
16
		sum = sum + pow(tempNumber, digits);
17
	}
18
	cout << sum << endl;
19
	if(sum == input)
20
	{
21
		cout << "True" << endl;
22
	}
23
	else
24
	{
25
		cout << "False" << endl;
26
	}
27
}
28
29
int main()
30
{
31
	int input = 153;
32
	ArmStrongNumberCheck(input);
33
	
34
	
35
}