using System;
struct Sscore
{
public string id; //定义实例成员
public string cno;
public int cj;
public Sscore( string id,string cno,int cj)//构造
{
this.id=id;
this.cno=cno;
this.cj=cj;
}
class Test
{
static void Main()
{
Sscore[] exp = new Sscore[3];
for (int i = 0; i <3; i++)
{
Console.WriteLine("请输入学生的学号:");
string strid=Console.ReadLine();
Console.WriteLine("请输入学生的课号:");
string strcno=Console.ReadLine();
Console.WriteLine("请输入学生的成绩:");
int stucj=int.Parse(Console.ReadLine());
exp[i]=new Sscore(strid,strcno,stucj); }
Console.WriteLine("请输入要查询学生的学号:");
string sno = Console.ReadLine();
Console.WriteLine("学号为{0}的学生:", sno);
for (int i = 0; i < 3; i++)
if (exp[i].id == sno)
{
Console.WriteLine("课程号{0}的成绩是{1}分:", exp[i].id, exp[i].cj);
}
}
}
struct Sscore
{
public string id; //定义实例成员
public string cno;
public int cj;
public Sscore( string id,string cno,int cj)//构造
{
this.id=id;
this.cno=cno;
this.cj=cj;
}
class Test
{
static void Main()
{
Sscore[] exp = new Sscore[3];
for (int i = 0; i <3; i++)
{
Console.WriteLine("请输入学生的学号:");
string strid=Console.ReadLine();
Console.WriteLine("请输入学生的课号:");
string strcno=Console.ReadLine();
Console.WriteLine("请输入学生的成绩:");
int stucj=int.Parse(Console.ReadLine());
exp[i]=new Sscore(strid,strcno,stucj); }
Console.WriteLine("请输入要查询学生的学号:");
string sno = Console.ReadLine();
Console.WriteLine("学号为{0}的学生:", sno);
for (int i = 0; i < 3; i++)
if (exp[i].id == sno)
{
Console.WriteLine("课程号{0}的成绩是{1}分:", exp[i].id, exp[i].cj);
}
}
}
Console.Write("请输入整数K的值:");
K=int.Parse(Console.ReadLine ());
if(K <=10)
K=K+1;
else if(10 <K && K<=20) //条件不正确
K-=10;
else if(K>30)
K=K*2-20;
Console.WriteLine("K={0}", K);
1.K的大小写
2.ReadLine不是Readline
3.else if(K>10&&K <=20)