菜鸟初学 求大神指教
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace student
{
class Program
{
static void Main(string[] args)
{
int [] a=new int[10];
int[] b =new int[10];
int[] c = new int[10];
int s = 0, m;
string str,str1,str2,str3;
for ( m = 0; m < 10; m++)
{
Console.WriteLine("请输入{0}学号", m+1);
str=Console.ReadLine();
a[m] = Convert.ToInt32(str);
Console.WriteLine("请输入{0}姓名", m+1);
str1 = Console.ReadLine();
Console.WriteLine("请输入{0}数学成绩",m+1);
str2 = Console.ReadLine();
b[m] = Convert.ToInt32(str2);
Console.WriteLine("请输入{0}语文成绩", m+1);
str3 = Console.ReadLine();
c[m] = Convert.ToInt32(str3);
}
for ( m = 0; m < 10; m++)
{
s = s + b[m] + c[m];
}
Console.WriteLine("学号是{1},姓名是{2},数学成绩是{3},语文成绩是{4},语文数学的和是{5}",a[m],str1 ,b[m],c[m],s);
Console .ReadKey ();
}
}
}
菜鸟初学求解答using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace student
{
class Program
{
static void Main(string[] args)
{
int [] a=new int[10];
int[] b =new int[10];
int[] c = new int[10];
int s = 0, m;
string str,str1,str2,str3;
for ( m = 0; m < 10; m++)
{
Console.WriteLine("请输入{0}学号", m+1);
str=Console.ReadLine();
a[m] = Convert.ToInt32(str);
Console.WriteLine("请输入{0}姓名", m+1);
str1 = Console.ReadLine();
Console.WriteLine("请输入{0}数学成绩",m+1);
str2 = Console.ReadLine();
b[m] = Convert.ToInt32(str2);
Console.WriteLine("请输入{0}语文成绩", m+1);
str3 = Console.ReadLine();
c[m] = Convert.ToInt32(str3);
}
for ( m = 0; m < 10; m++)
{
s = s + b[m] + c[m];
}
Console.WriteLine("学号是{1},姓名是{2},数学成绩是{3},语文成绩是{4},语文数学的和是{5}",a[m],str1 ,b[m],c[m],s);
Console .ReadKey ();
}
}
}
为什么说使用了未赋值的局部变量“str1”求大神指导