+ 2

New driver license Problem

Hi Evrybody me again ! I have problem with solution in new driver license. I cannot pass case 1 and case3. That is my code : string s = Console.ReadLine(); double number = Convert.ToInt32(Console.ReadLine()); string name = Console.ReadLine(); var xyz = name.Split(','); var xanax = xyz.Concat(new[] { s }); var z = xanax.ToArray(); Array.Sort(z); double time = 0; for (int i = 0; i < z.Length; i++) { if (z[i] == s) { double x = ++i; time = (x / number); var y = Math.Ceiling(time) * 20; Console.WriteLine(y); } } On my computer program pass case1, but on application Not ! Can someone help me ? Thanks Kajman !

7th Jan 2020, 6:10 PM
Kajman 🇵🇱
6 Antworten
+ 4
Kajman, your code works, if you just change the line where you split the users. The task says by whitespace, you split by comma, make it by whitespace 🐱
7th Jan 2020, 6:56 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { String name=Console.ReadLine(); int number=Convert.ToInt32(Console.ReadLine()); String allname=Console.ReadLine(); allname=name+" "+allname; String[] words=allname.Split(" "); Array.Sort(words); int a=Array.IndexOf(words,name)+1; int b; if (number>=a) { b=20; } else { b=(((a)-number)+1)*20; } Console.WriteLine(b); } } }
18th Aug 2021, 2:57 PM
Namdar Vali
Namdar Vali - avatar
0
Thx cat. 🙈 I am inattentive 😅
7th Jan 2020, 7:01 PM
Kajman 🇵🇱
30th Jul 2021, 6:47 AM
Ankit Kumar
Ankit Kumar - avatar
0
It works successfully
30th Jul 2021, 6:47 AM
Ankit Kumar
Ankit Kumar - avatar
- 3
You
24th Jan 2020, 7:57 PM
Sultan