7+5=12
12:2=6
6+3=9
6-1=8
4*5=20
20-3=17
17*3=51
51+4=55
#include <iostream>
#include <cmath>
using namespace std;
void isArmstrong(const int number)
{
int origNum, num, rem, sum = 0;
origNum = number;
num = origNum;
while(num != 0) {
rem = num % 10;
sum += pow(rem, 3);
num /= 10;
}
if(sum == origNum)
cout << origNum << " is an Armstrong number.";
else
cout << origNum << " is not an Armstrong number.";
}
int main()
{
isArmstrong(153);
return 0;
}
_________________________
С проверкой https://ideone.com/keY6PS
<span>#include<span> <iostream>
</span>#include<span> <cstring>
</span>
int main() {
char* text1 = "Слово"<span>;
</span> char* text = "Как то текст с гласными на конце кок"<span>;
</span>
char* newText = new char[strlen(text)]<span>;
</span>
int lastStop = 0, lastIter = 0<span>;
</span> for (int i = 0; text[i] != '\0'; i++) {
bool copyIt = false<span>;
</span>
if (text[i] == ' ') lastStop = i<span>;
</span>
if (text[i + 1] == ' ' || text[i + 1] == '\0') {
for (int j = 0; text1[j] != '\0'; j++) {
if (text[i] == text1[j]) {
copyIt = false; break<span>;
</span> }
copyIt = true<span>;
</span> }
}
if (copyIt == true) {
for (int j = lastStop; j <= i; j++, lastIter++)
newText[lastIter] = text[j]<span>;
</span> }
}
for (int i = 0; i < lastIter; i++)
std::cout << newText[i]<span>;
</span>
std::cout << "\n"<span>;
</span>
return 0<span>;
</span>}</span>
Var n, i, k, s: integer;
begin
readln(n);
for i:=1 to n do
begin
readln(k);
if abs(k)>i then s:=s+k;
end;
writeln(s);
end.