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 ConsoleApplication11
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[10];
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write("Kérem az " + (i + 1) + ". elemet: ");
- array[i] = int.Parse(Console.ReadLine());
- }
- if (szamtan(array))
- {
- Console.WriteLine("A tömb növekvő számtani sorozatot alkot.");
- }
- else
- {
- Console.WriteLine("A tömb nem alkot növekvő számtani sorozatot.");
- }
- }
- static bool szamtan(int[] tomb)
- {
- int kul = tomb[1]-tomb[0];
- bool ell = true;
- if (kul < 0) { ell = false; }
- for (int i = 2; i < tomb.Length && ell; i++)
- {
- if (tomb[i] - tomb[i-1] != kul)
- {
- ell = false;
- }
- }
- return ell;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement