Created
December 24, 2016 14:14
-
-
Save Soulstorm50/5ca088cc97bdebb1dbc017ae41fe6c52 to your computer and use it in GitHub Desktop.
Между двумя девятками в числе Pi C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
string s = "3,141592653589793238469"; | |
Console.WriteLine("{0}", s); | |
int first = s.IndexOf('9'), second = first >= 0 ? s.IndexOf('9', first + 1) : -1; | |
int count = first != second && second >= 0 ? second - first - 1 : -1; | |
int three = second >= 0 ? s.IndexOf('9', second + 1) : -1; | |
int count2 = second != three && three >= 0 ? three - second - 1 : -1; | |
int four = three >= 0 ? s.IndexOf('9', three + 1) : -1; | |
int count3 = three != four && four >= 0 ? four - three - 1 : -1; | |
Console.WriteLine("между двумя девятками находятся {0} потом, {1} потом, {2} ", count, count2, count3); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment