Back to General discussions forum
|It's my cod. and why doesn't it work? I mean, my answer is right, but site doesn't accept. because the expected result has one different answer from the rest. they have 10 values after the point, but one or two have 11 values.
using System;
using System.IO;
class Program24
{
static void Main()
{
StreamReader art = new StreamReader("C:\\text.txt");
int data = Convert.ToInt32(art.ReadLine());
string[] input = art.ReadLine().Replace(".", ",").Split(' ');
Console.Write(input[0] + " ");
for (int all = 1; all < data - 1; all++)
{
double a = double.Parse(input[all - 1]);
double b = double.Parse(input[all]);
double c = double.Parse(input[all + 1]);
b = (a + b + c) / 3;
Console.Write("{0:0.##########} ",b);
}
Console.Write(input[input.Length - 1] + " ");
}
}
Hi! Try output your answer this code:
Console.Write(Math.Round(b, 7).ToString().Replace(',','.') + " ");
Hi! Thank you. Your advice really helped. But why is my option wrong because this "," is wrong?
can you hide or delete my code from those who has not done