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 számtani sorozatot alkot.");
- }
- else
- {
- Console.WriteLine("A tömb nem alkot számtani sorozatot.");
- }
- }
- static bool szamtan(int[] tomb)
- {
- int kul = tomb[1]-tomb[0];
- for (int i = 2; i < tomb.Length; i++)
- {
- if (tomb[i] - tomb[i-1] != kul)
- {
- return false;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement