%를 계산하고 다음 형식으로 결과를 제공하려는 통계를 찾고 싶습니다. WX GSA 검색 % = GSA 발생 수/GSA 발생 수 + 검색 발생 수 + ADVSearch 발생 수 * 100 즉이 경우 3/3과 같아야합니다. + 2 + 2 * 100 = 나는 모든 검색의 발생을 줄 것이다 코드를 시도 42.8C sharp를 사용하여 현명한 통계를 계산 하시겠습니까?
:
내 코드는 여기에 있습니다 :
class Program
{
static void Main()
{
System.IO.StreamReader myFile =
new System.IO.StreamReader(@"C:\Users\karansha\Desktop\sample log.txt");
string myString = myFile.ReadToEnd();
Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX Search")); // WX Rule Based Search.
Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX GSA Search")); // WX GSA Search.
Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX ADVSearch")); //WX Form Based Search.
// keep screen from going away
// when run from VS.NET
Console.ReadLine();
}
}
public static class TextTool
{
public static int CountStringOccurrences(string text, string pattern)
{
int count = 0;
int i = 0;
while ((i = text.IndexOf(pattern, i)) != -1)
{
i += pattern.Length;
count++;
}
return count;
}
}
나는 다음과 같은 형식으로 로그가 : WX GSA 검색 = 서버 : yukon.corp.wx.com WX GSA 검색 = 서버 : yukon.corp.wx합니다. com WX GSA 검색 = 서버 : yukon.corp.wx.com WX 검색 = 서버 : yukon.corp.wx.com WX 검색 = 서버 : yukon.corp.wx.comWX ADVSearch = 서버 : yukon.corp.wx. com WX ADVSearch = 서버 : yukon.corp.wx.com –
[무엇을 시도 했습니까?] (http://whathaveyoutried.com) 또한 의견으로 추가하는 대신 질문에 추가 정보를 편집하십시오. – Nuffin
내가 찾고 싶습니다. 연령을 계산하고 다음 형식으로 결과를 제공하는 통계 : WX GSA 검색 % = GSA 발생 수/GSA 발생 수 + 검색 발생 수 + ADVSearch 발생 수 * 100 즉,이 경우 3/3 + 2 + 2 * 100 = 42.8과 같아야합니다. –