+ 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 Antworten
+ 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