Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DZ_ip
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- while (true)
- {
- Console.Write("Введите ip:");
- string ip = Console.ReadLine();
- if(NextIP(ip) == null)
- {
- Console.WriteLine("Вы ввели неверный IP");
- continue;
- }
- Return(NextIP(ip));
- }
- }
- static byte[] NextIP (string ip)
- {
- string[] ipArray = ip.Split('.');
- byte[] ipByte = new byte[ipArray.Length];
- for (int i = 0; i < ipArray.Length; i++)
- {
- if (Convert.ToInt32(ipArray[i]) > 255)
- {
- ipByte = null;
- break;
- }
- ipByte[i] = Convert.ToByte(ipArray[i]);
- }
- return ipByte;
- }
- static void Return (byte[] ip)
- {
- for (int i = ip.Length - 1; i >= 0; i--)
- {
- ip[i] += 1;
- if(ip[i] != 0)
- {
- break;
- }
- }
- for (int i = 0; i < ip.Length; i++)
- {
- Console.Write(ip[i] + ".");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement