using System;
using System.Collections.Generic;
using System.Linq;
namespace
{
class App
static void Main(string[] argv)
App Obj = new App();
Obj.Run();
}
public bool IsContains(string Word, char searched_lit)
char[] lits = Word.ToCharArray();
foreach (char lit in lits)
if (lit == searched_lit)
return true;
return false;
public void Run()
int N = Convert.ToInt32(Console.ReadLine());
List<string> nums = new List<string>();
List<int> dual_number = new List<int>();
for (int i = 1; i <= N; i++)
nums.Add(Console.ReadLine());
foreach (string word in nums)
if (word.Length == 2)
if (IsContains(word, '4'))
dual_number.Add(Convert.ToInt32(word));
int result=0;
dual_number.ForEach(x => result += x);
Console.WriteLine(result / dual_number.Count);
Console.ReadKey();
Объяснение:
using System;
using System.Collections.Generic;
using System.Linq;
namespace
{
class App
{
static void Main(string[] argv)
{
App Obj = new App();
Obj.Run();
}
public bool IsContains(string Word, char searched_lit)
{
char[] lits = Word.ToCharArray();
foreach (char lit in lits)
{
if (lit == searched_lit)
{
return true;
}
}
return false;
}
public void Run()
{
int N = Convert.ToInt32(Console.ReadLine());
List<string> nums = new List<string>();
List<int> dual_number = new List<int>();
for (int i = 1; i <= N; i++)
{
nums.Add(Console.ReadLine());
}
foreach (string word in nums)
{
if (word.Length == 2)
{
if (IsContains(word, '4'))
{
dual_number.Add(Convert.ToInt32(word));
}
}
}
int result=0;
dual_number.ForEach(x => result += x);
Console.WriteLine(result / dual_number.Count);
Console.ReadKey();
}
}
}
Объяснение: