Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace StamProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime now;
- while (true)
- {
- now = DateTime.Now;
- Console.WriteLine(now);
- System.Threading.Thread.Sleep(1000);
- Console.Clear();
- }
- }
- static void PerfectNumber()
- {
- int num, i, check;
- string calculation = null;
- while (true)
- {
- num = int.Parse(Console.ReadLine());
- i = num - 1;
- check = 0;
- while (i > 0)
- {
- if (num % i == 0)
- {
- if (i != 1)
- {
- calculation += i + " + ";
- }
- else
- {
- calculation += "1";
- }
- check += i;
- }
- i--;
- }
- if (num == check)
- Console.WriteLine("Number {0} is a perfect number.\n{1} = {0}", num, calculation);
- }
- }
- static void Page151Exercise37()
- {
- int maxLength = 0, currentLength = 0, num1, num2 = 0;
- num1 = int.Parse(Console.ReadLine());
- while (num1 != 0)
- {
- if (num1 > num2)
- currentLength++;
- else
- currentLength = 1;
- if (currentLength > maxLength)
- maxLength = currentLength;
- num2 = num1;
- num1 = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("Maximum length: " + maxLength);
- }
- static void Page151Exercise33()
- {
- int countCondition = 0;
- double num1, num2;
- num1 = double.Parse(Console.ReadLine());
- num2 = num1;
- while (num1 != 0)
- {
- if (num1 < num2)
- countCondition++;
- num2 = num1;
- num1 = double.Parse(Console.ReadLine());
- }
- Console.WriteLine("\n{0}", countCondition);
- }
- static void LongestDigitsSequence()
- {
- int num1, num2, count = 0, maxCount = 0;
- num1 = int.Parse(Console.ReadLine());
- num2 = num1;
- while (num1 != -1)
- {
- if (num1 == 0)
- num1 = 10;
- if (num1 == num2 + 1)
- count++;
- else
- count = 1;
- if (count > maxCount)
- maxCount = count;
- num2 = num1;
- num1 = int.Parse(Console.ReadLine());
- }
- Console.WriteLine(maxCount);
- }
- static void Exercise63Numbers()
- {
- int n, num1 = 0, num2 = int.MaxValue, middleNum = 0, difference = int.MaxValue;
- string couple = null;
- decimal avg, sum = 0;
- n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- if (i != 0)
- num2 = num1;
- num1 = int.Parse(Console.ReadLine());
- if (i == Math.Floor((double)n / 2))
- middleNum = num1;
- if ((num1 - num2) < difference)
- {
- difference = num2 - num1;
- couple = num1.ToString() + " , " + num2.ToString();
- }
- sum += num1;
- }
- avg = sum / n;
- Console.WriteLine("Average: {0} Middle number: {1} Smallest: {2}", avg, middleNum, couple);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement