Четверг, 25.04.2024, 17:56
Информатика и математика в Плесской школе
Приветствую Вас Гость | RSS
Меню сайта
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
Форма входа
С новым 2017 годом. Елка программиста...
С новым годом однако... Это третья версия новогодней елки за сегодняшнее замечательное утро 1 января 2017 года.... Это реплика на https://vk.com/cat_programming?w=wall-63708206_218850 Предлагаю два решения, на С# и Pascal ABC NET
 
С# 
 
Исходный код на С#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
// для команды задержки на время Thread.Sleep(100)

 

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = new int[40];
            int[] y = new int[40];
            int i;
           

            Random rnd= new Random();
         
  // цвет консоли и закраска в данный цвет

            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();

            // цвет рисования
            Console.ForegroundColor = ConsoleColor.Red;
             Console.SetCursorPosition(40, 1);
             Console.Write("1");
             Console.ForegroundColor = ConsoleColor.Green;
            Console.SetCursorPosition(39,2); Console.Write("000");
            Console.SetCursorPosition(38,3); Console.Write("00000");
            Console.SetCursorPosition(37,4); Console.Write("0000000");
            Console.SetCursorPosition(36,5); Console.Write("000000000");
            Console.SetCursorPosition(38,6); Console.Write("00000");
            Console.SetCursorPosition(37,7); Console.Write("0000000");
            Console.SetCursorPosition(36,8); Console.Write("000000000");
            Console.SetCursorPosition(35,9); Console.Write("00000000000");
            Console.SetCursorPosition(34,10); Console.Write("0000000000000");
            Console.SetCursorPosition(33,11); Console.Write("000000000000000");
            Console.SetCursorPosition(37,12); Console.Write("0000000");
            Console.SetCursorPosition(36,13); Console.Write("000000000");
            Console.SetCursorPosition(35,14); Console.Write("00000000000");
            Console.SetCursorPosition(34,15); Console.Write("0000000000000");
            Console.SetCursorPosition(33,16); Console.Write("000000000000000");
            Console.SetCursorPosition(32,17); Console.Write("00000000000000000");
            Console.SetCursorPosition(31,18); Console.Write("0000000000000000000");
            Console.SetCursorPosition(30,19); Console.Write("000000000000000000000");
            Console.SetCursorPosition(29,20); Console.Write("00000000000000000000000");
            Console.SetCursorPosition(39,21); Console.Write("000");
             Console.SetCursorPosition(39,22); Console.Write("000");
             do
             {
                 for (i=1;i<40;i++) 
                 {
                  y[i]=rnd.Next(2,21);
                  if (y[i]==2)  x[i]=rnd.Next(39,41); 
                  if (y[i]==3)  x[i]=rnd.Next(38,42); 
                  if (y[i]==4)  x[i]=rnd.Next(37,43); 
                  if (y[i]==5)  x[i]=rnd.Next(36,44); 
                  if (y[i]==6)  x[i]=rnd.Next(38,42); 
                  if (y[i]==7)  x[i]=rnd.Next(37,43); 
                  if (y[i]==8)  x[i]=rnd.Next(36,44); 
                  if (y[i]==9)  x[i]=rnd.Next(35,45); 
                  if (y[i]==10) x[i]=rnd.Next(34,46); 
                  if (y[i]==11) x[i]=rnd.Next(33,47); 
                  if (y[i]==12) x[i]=rnd.Next(37,43); 
                  if (y[i]==13) x[i]=rnd.Next(36,44); 
                  if (y[i]==14) x[i]=rnd.Next(35,45); 
                  if (y[i]==15) x[i]=rnd.Next(34,46); 
                  if (y[i]==16) x[i]=rnd.Next(33,47);
                  if (y[i] == 17) x[i] = rnd.Next(32, 48);
                  if (y[i] == 18) x[i] = rnd.Next(31, 49);
                  if (y[i] == 19) x[i] = rnd.Next(30, 50);
                  if (y[i] == 20) x[i] = rnd.Next(29, 51);
                  
                     int c=rnd.Next(1, 15);
                     if (c == 1) Console.ForegroundColor = ConsoleColor.Blue;
                     if (c == 2) Console.ForegroundColor = ConsoleColor.Cyan;
                     if (c == 3) Console.ForegroundColor = ConsoleColor.DarkBlue;
                     if (c == 4) Console.ForegroundColor = ConsoleColor.DarkCyan;
                     if (c == 5) Console.ForegroundColor = ConsoleColor.DarkGray;
                     if (c == 6) Console.ForegroundColor = ConsoleColor.DarkGreen;
                     if (c == 7) Console.ForegroundColor = ConsoleColor.DarkMagenta;
                     if (c == 8) Console.ForegroundColor = ConsoleColor.DarkRed;
                     if (c == 9) Console.ForegroundColor = ConsoleColor.DarkYellow;
                     if (c == 10) Console.ForegroundColor = ConsoleColor.Gray;
                     if (c == 11) Console.ForegroundColor = ConsoleColor.Green;
                     if (c == 12) Console.ForegroundColor = ConsoleColor.Magenta;
                     if (c == 13) Console.ForegroundColor = ConsoleColor.Red;
                     if (c == 14) Console.ForegroundColor = ConsoleColor.White;
                     if (c == 15) Console.ForegroundColor = ConsoleColor.Yellow;
                  Console.SetCursorPosition(x[i],y[i]); Console.Write("X");
                  }

                 Thread.Sleep(100); // задержка

                 for (i = 1; i < 40; i++)
                 {
                     Console.ForegroundColor = ConsoleColor.Green;
                     Console.SetCursorPosition(x[i], y[i]); Console.Write("0");
                 }

                 
             }
             while (Console.KeyAvailable == false);     
           
// цикл выполняется пока не нажата любая клавиша

        }
    }

}

Pascal ABC NET

Исходный код на Pascal ABC NET:
program n1; 
uses crt; 
var x:array[1..30] of integer; 
y:array[1..30] of integer; 
i:integer; 
begin 
TextBackGround(White); 
clrscr; 
TextColor(red); 
gotoxy(40,1); 
writeln('1'); 
TextColor(Green); 
gotoxy(39,2); writeln('000'); 
gotoxy(38,3); writeln('00000'); 
gotoxy(37,4); writeln('0000000'); 
gotoxy(36,5); writeln('000000000'); 
gotoxy(38,6); writeln('00000'); 
gotoxy(37,7); writeln('0000000'); 
gotoxy(36,8); writeln('000000000'); 
gotoxy(35,9); writeln('00000000000'); 
gotoxy(34,10); writeln('0000000000000'); 
gotoxy(33,11); writeln('000000000000000'); 
gotoxy(37,12); writeln('0000000'); 
gotoxy(36,13); writeln('000000000'); 
gotoxy(35,14); writeln('00000000000'); 
gotoxy(34,15); writeln('0000000000000'); 
gotoxy(33,16); writeln('000000000000000'); 
gotoxy(32,17); writeln('00000000000000000'); 
gotoxy(31,18); writeln('0000000000000000000'); 
gotoxy(30,19); writeln('000000000000000000000'); 
gotoxy(29,20); writeln('00000000000000000000000'); 
gotoxy(39,21); writeln('000'); 
gotoxy(39,22); writeln('000'); 
repeat 
for i:=1 to 30 do 
begin 
y[i]:=random(2,20); 
if (y[i]=2) then x[i]:=random(39,41); 
if (y[i]=3) then x[i]:=random(38,42); 
if (y[i]=4) then x[i]:=random(37,43); 
if (y[i]=5) then x[i]:=random(36,44); 
if (y[i]=6) then x[i]:=random(38,42); 
if (y[i]=7) then x[i]:=random(37,43); 
if (y[i]=8) then x[i]:=random(36,44); 
if (y[i]=9) then x[i]:=random(35,45); 
if (y[i]=10) then x[i]:=random(34,46); 
if (y[i]=11) then x[i]:=random(33,47); 
if (y[i]=12) then x[i]:=random(37,43); 
if (y[i]=13) then x[i]:=random(36,44); 
if (y[i]=14) then x[i]:=random(35,45); 
if (y[i]=15) then x[i]:=random(34,46); 
if (y[i]=16) then x[i]:=random(33,47); 
if (y[i]=17) then x[i]:=random(32,48); 
if (y[i]=18) then x[i]:=random(31,49); 
if (y[i]=19) then x[i]:=random(30,50); 
if (y[i]=20) then x[i]:=random(29,51); 
TextColor(random(1,15)); 
gotoxy(x[i],y[i]); writeln('X'); 
end; 
delay(200); 
for i:=1 to 30 do 
begin 
TextColor(Green); 
gotoxy(x [i],y[i]); writeln('0'); 
end; 
until keypressed; 
end.
 
Поиск
Календарь
«  Апрель 2024  »
ПнВтСрЧтПтСбВс
1234567
891011121314
15161718192021
22232425262728
2930
Архив записей
Друзья сайта
  • Официальный блог
  • Сообщество uCoz
  • FAQ по системе
  • Инструкции для uCoz
  • Учительский портал
    Copyright MyCorp © 2024