Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Lesson8
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] ar=new int[0];
- string inputStr;
- do
- {
- Console.WriteLine("Введите число или слово sum");
- inputStr = Console.ReadLine();
- if (!inputStr.Contains("sum"))
- {
- int[] buf = new int[ar.Length];
- for(int i = 0; i < ar.Length; i++)
- {
- buf[i] = ar[i];
- }
- ar = new int[buf.Length+1];
- for (int i = 0; i < buf.Length; i++)
- {
- ar[i]=buf[i];
- }
- ar[ar.Length - 1] = Convert.ToInt32(inputStr);
- }
- } while (!inputStr.Contains("sum"));
- int sum=0;
- for (int i=0;i<ar.Length;i++)
- {
- sum += ar[i];
- }
- Console.WriteLine("Сумма всех ячеек: "+sum+"\nСортировка");
- int temp;
- for (int i = 0; i < ar.Length - 1; i++)
- {
- for (int j = i + 1; j < ar.Length; j++)
- {
- if (ar[i] > ar[j])
- {
- temp = ar[i];
- ar[i] = ar[j];
- ar[j] = temp;
- }
- }
- }
- for (int i = 0; i < ar.Length; i++)
- {
- Console.Write(ar[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement