0
이 코드가 배열을 표시하는 데 도움이 필요하지만 코드 구조는 동일하게 유지되어야합니다. 감사을 표시 할 수 없습니다.
class Program
{
static void Main()
{
collectStudentDetails();
promptForStudentQuery();
printStudentsmarks();
Console.ReadLine();
}
public static void collectStudentDetails()
{
Console.WriteLine("Please Specifiy How Many Student Details You Wish To Enter");
Console.WriteLine("");
int n = SafeReadInteger(0);
int[] StudentMarks = new int[n];
string[] StudentNames = new string[n];
for (int i = 0; i < StudentNames.Length; i++)
{
Console.WriteLine("Enter Name for student {0}", i + 1);
StudentNames[i] = SafeReadString(null);
Console.WriteLine("Enter Mark for Student {0}: ", i + 1);
StudentMarks[i] = SafeReadInteger(0);
}
}
static void findStudentmark()
{
bool foundStudent = false;
Console.WriteLine("Please Enter The Students Name To Find Their Marks");
Console.WriteLine("Please Press Enter To Continue");
Console.ReadLine();
}
static void printStudentsmarks()
{
Console.WriteLine("\nStudent Mark List");
Console.WriteLine("Please Press Enter To Continue");
Console.ReadLine();
promptForStudentQuery();
}
static bool promptForStudentQuery()
{
bool promptAgain = true;
Console.WriteLine();
Console.WriteLine(" 1. find a student's mark ");
Console.WriteLine(" 2. print all student marks");
Console.WriteLine(" 3. exit ");
Console.WriteLine();
int choice = SafeReadInteger(0);
if (choice == 1)
{
findStudentmark();
}
else if (choice == 2)
{
printStudentsmarks();
}
else if (choice == 3)
{
Environment.Exit(0);
}
else if (choice == 0)
{
Console.WriteLine("you entered an invalid option try again");
}
return promptAgain;
}
public static int SafeReadInteger(int defaultVal)
{
try
{
return int.Parse(System.Console.ReadLine());
}
catch
{
return defaultVal;
}
}
public static string SafeReadString(string defaultVal)
{
string temp = "";
temp = Console.ReadLine();
while (temp == "")
{
Console.WriteLine("You have entered nothing. Please enter a correct value.");
temp = Console.ReadLine();
}
return temp;
}
static void DisplayArray(int[] inputarray)
{
foreach (int x in inputarray)
{
Console.Write(" {0} ", x);
}
Console.WriteLine("");
}
static void DisplayArray2(string[] inputarray)
{
foreach (string x in inputarray)
{
Console.Write(" {0} ", x);
}
Console.WriteLine("");
}
}
을 내가 두 배열을 만들었습니다와 나는 각각의 방법에서 모두 표시해야하고, 나 또한 검색하고 학생들의 자국이 난 다 정말 도움을 필요로 한 나의 첫 번째 코드입니다 를 입력 표시해야
은 당신이 정말로 코드의 6 페이지 ** 우리는 당신을 돕기 위해 볼 수있는 ** 최소 생각하십니까? – Snowbear
오랫동안 죄송합니다. 그 구조에 있어야하는 목록을 사용하지 마십시오. – mitch
@nadirs, true가 아님 – Habib