Last active
August 1, 2020 20:44
-
-
Save Medvedoc/fe6dda36156651cb4b5cf5ca442812d9 to your computer and use it in GitHub Desktop.
My_tasks_Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
/* | |
Задача 2 | |
Определите количество десятичных цифр в целом числе без знака. Например, 7 представляет собой одну цифру, 33 имеет 2 цифры, а 129955 имеет 6 цифр. | |
Условие: использовать length нельзя. | |
Входные данные:2,555,236455 | |
Выходные данные:1,3,6 | |
*/ | |
//Задание 2 | |
//Задание выполнено 2 вариантами | |
print('Вариант 1'); | |
List<double> years1 = [2, 555, 236455]; | |
for (int i = 0; i < years1.length; i++) { | |
int counter1 = 0; | |
do { | |
counter1++; | |
years1[i] /= 10; | |
} while | |
(years1[i] >1); | |
print (counter1); | |
} | |
print(''); | |
print('Вариант 2'); | |
List<double> years2 = [2, 555, 236455]; | |
for (int i2 = 0; i2 < years2.length; i2++) { | |
int counter2 = 0; | |
while (years2[i2]>1){ | |
years2[i2] /=10; | |
counter2++; | |
} | |
print(counter2); | |
} | |
print(''); | |
print('Вариант 3'); | |
int counter = 1, number = 777; | |
while((number ~/=10)>1) | |
counter++; | |
print(counter); | |
} | |
//Подсказки | |
// /= - делит левый операнд на правый операнд и присваивает результат левому операнду |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment