search points attachment profile arrow left arrow right star heart verified symbols equation arrow-down question mark check menu accountancyadministrationagriculturalalgebraallarabicartart_musicbelarusbelarus_altbiologybusinesscatalachemistrychineseeconomicsegzamenglishentrepreneurshipenvironmentethicseuskarafirst_aidfrenchgalegogeographygeologygeometrygermangrammarhealthhistoryindia_langindonesian_langinformaticsitalianjapanesekazachkazach_altkoreanlanguagelatinlawlife_scienceliteraturelogicmathematicsmusicnigerian_langother_languagesotherspedagogicsphilosophyphysical_educationphysicspoliticspsychologyreligionrpa_langrussianrussian_altsciencesecurityskillssocial_sciencesociologyspanishstatisticstechnologytourismtrafficukrainianukrainian_altukrainian_literaturewos_civilisation accountancyadministrationagriculturalalgebraall_1arabicartart_music_2belarusbelarus_altbiologybusiness_2catalachemistry_1chineseeconomicsexam_3englishentrepreneurshipenvironment_2ethicseuskarasecurity_1frenchgalegogeography_4geology_4geometrygermangrammarhealthhistoryindia-langindonesian-langinformaticsitalianjapanesekazachAsset 230koreanlanguagelatinlawlife-scienceliteraturelogic_2mathematicsmusicnigerian-langotherlanguagesother_1pedagogicsphilosophyphysical_educationphysicspoliticspsychologyreligion_1rpa-langrussianrussian_altsciencesecurity_3_mskills_1allsocial_science_5_msociologyspanishstatisticstechnologytourismtrafficukrainianukrainian_altukrainian_literaturewos_civilisation

Ответ

Ответ дан
Koljisto

#include <iostream>

#include <time.h>

#include <vector>

#include <numeric>

#include <algorithm>

using namespace std;

int find_digital_root(int elem) {

vector<int> temp_vec;

int sum = 0;

while (elem != 0) {

 temp_vec.push_back(elem % 10);

 elem = elem / 10;

}

if (temp_vec.size() == 1) {

 return temp_vec[0];

}

else {

 sum = accumulate(temp_vec.begin(), temp_vec.end(), 0);

 temp_vec.clear();

 return find_digital_root(sum);

}

}

int main()

{

int temp = 0;

for (int i = 100; i <= 200; i++)

{

 temp = find_digital_root(i);

 if (temp == 1 || temp == 2 || temp == 3 || temp == 5 || temp == 7) {

  cout << i << endl;

 }

}

}

Ответы и объяснения

Не тот ответ, который тебе нужен?


По всем вопросам пишите на - [email protected]