All 5-letter words composed of the letters A, O, and U are written in alphabetical order. Here is the beginning of the list:
- AAAAA
- AAAAO
- AAAAU
- AAAOA ……
Write down the word that is on the 240th place from the beginning of the list.
All 5-letter words composed of the letters A, O, and U are written in alphabetical order. Here is the beginning of the list:
Write down the word that is on the 240th place from the beginning of the list.
Something like this:
char str[6]={0}; char chars[3]={'A', 'O', 'Y'}; //Для перевода троичных цифр в буквы int a; cin >> a; a--; //В коде отсчёт идёт с нуля, а не с единицы, как по условию задачи //Переводим в троичную систему делением на 3 и записыванием остатка в обратном порядке for(int pos=4; pos>=0; pos--) { str[pos]=chars[a%3]; a/=3; } cout << str;
Source: https://ru.stackoverflow.com/questions/55340/
All Articles