+ 4
Can someone debug this?
I dont know what importing modules should i add, and im a beginner at c#, this code is originally implemented in java, Thank you? â€ïžâ€ïž https://code.sololearn.com/cG82bXodSZ5a/?ref=ap
7 Respostas
+ 2
Lia Costa âš there's no variable named output. Create a variable of type String.
String output="";
for(int i =0 ; i< X.Count; i++ )
if(i < X.Count-1){
output+=""+X[i]+"\t"+", ";
}else{
output+=""+X[i];
}
Console.WriteLine("["+output+"]");
+ 3
That error was because of missing namespace and class.
This one is correct though,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sololearn {
class myclass{
static void Main(string[] args)
{
int a=2,c =1;
List<int> X = new List<int>();
X.Insert(0,0);
//user input to m :
int m = Convert.ToInt32(Console.ReadLine());
for(int n =0 ; n<m; n++)
X.Insert(n+1,((a*X[n]+ c) % m));
for(int i =0 ; i< X.Count; i++ )
Console.Write(X[i]+"\t");
}
}
}
+ 2
0_O-[MĂ€gĂĄr_SĂĄm_ĂkĂ _NĂŒllpÞïntĂȘr_ĂxĂ«cĂ©ptïön]~~ Thank you for the help! đđ»â€ïž
+ 1
0_O-[MĂ€gĂĄr_SĂĄm_ĂkĂ _NĂŒllpÞïntĂȘr_ĂxĂ«cĂ©ptïön]~~ can you add some commas in between and a bracket for the set of numbers on the output? Im not sure how to do that
+ 1
also thank you so much!
+ 1
Lia Costa âš it's too simple, there are others several ways too but this one is very simple.
for(int i =0 ; i< X.Count; i++ )
if(i < X.Count-1){
output+=""+X[i]+"\t"+",";
}else{
output+=""+X[i];
}
Console.WriteLine("["+output+"]");
}
+ 1
https://code.sololearn.com/ci0S0S7vKb46/?ref=app
it says output doesnt exist in the current context, im sorry im too slow