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;
- using System.Threading.Tasks;
- namespace Саня_и_Ромб
- {
- internal class Program
- {
- /*
- IV
- III 0
- II 0 000
- I 0 000 00000
- 0 -> 000 -> 00000 -> 0000000
- 1 0 000 00000
- ---> 5 0 000
- +4 -----> 13 0
- +8 ------> 25
- +12
- */
- static void Main(string[] args)
- {
- Console.WriteLine("Введите порядок ромба");
- int n = int.Parse(Console.ReadLine());
- int res = Calculate(n);
- Console.WriteLine(res);
- Console.ReadKey();
- }
- public static int Calculate(int n)
- {
- int result = 1;
- int temp = 0;
- for (int i = 1; i < n; i++)
- {
- temp += 4;
- result += temp;
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement