Составить программу, которая находит и выводит на печать все четырехзначные числа abcd - C# (179459)
Формулировка задачи:
Здравствуйте. Нужна помощь с задачами.
Нужно реализовать задачу с помощью циклов.
Составить программу, которая находит и выводит на печать все четырехзначные числа abcd
Решение задачи: «Составить программу, которая находит и выводит на печать все четырехзначные числа abcd»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] from_zero_to_nine = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- int[] from_one_to_nine = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- IEnumerator<int> ae = VaryDigits(from_one_to_nine, 1000, 1).GetEnumerator();
- IEnumerator<int> be = VaryDigits(from_zero_to_nine, 100, 10).GetEnumerator();
- IEnumerator<int> ce = VaryDigits(from_zero_to_nine, 10, 100).GetEnumerator();
- IEnumerator<int> de = VaryDigits(from_zero_to_nine, 1, 1000).GetEnumerator();
- while (ae.MoveNext())
- {
- be.MoveNext(); ce.MoveNext(); de.MoveNext();
- Console.Write(ae.Current + "" + be.Current + "" + ce.Current + "" + de.Current + " ");
- }
- }
- static IEnumerable<int> VaryDigits(int[] digits, int delay, int times)
- {
- for (int i = 0; i < times; i++)
- for (int j = 0; j < digits.Length; j++)
- for (int _ = 0; _ < delay; _++)
- yield return digits[j];
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д