for (int i = 0; i < values1.Length; i++) ;
{
int a = 0;
int b = values1[a];
if (b < 60)
{
b = 59;
}
else
{
Double[] scor;
switch (b)
{
case 59:
scor[a] = 0.00; break;
case 60:
scor[a] = 1.00; break;
case 61:
case 62:
case 63:出现这个错误是什么意思啊
解决方案 »
- 使用C#写了个wince小程序,用vs08,……求教关于键盘改键
- c# 访问iis7发生内存泄漏 ,在线等
- 收集System.io 经典操作
- 查询大量结果数据集业务逻辑的问题
- 请教一下hashtable有关问题
- 关于dateset!急,在线等!
- 如何用C#实现对文件的控制
- Winform问题:DateTimePicker在Enable为False时怎么改变字体颜色
- 为什么我我的PrintDocument在PrintPreviewDialog中预览是多页的,在打印的时候就只打印了最后一页呢???
- .net2003下不能创建工程,求助!!
- panle 和 toolstrip 同时设置dock为top后,如何使得toolstrip在panel的上方?
- C# 输入框组件如何实现自动产生千分位的逗号
Double[] scor = new Double[1];
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace jidianbate1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} Double gpa;
Double sum1 = 0.00;
Double sum2 = 0.00; private void buttontj1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("请输入要添加的数据");
}
else
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
} } private void buttonsc1_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItems.Count == 0)
{
MessageBox.Show("请选择要删除的项目");
}
else
{
listBox1.Items.Remove(listBox1.SelectedItem);
}
} private void buttontj11_Click(object sender, EventArgs e)
{
if (textBox2.Text == "")
{
MessageBox.Show("请输入要添加的数据");
}
else
{
listBox2.Items.Add(textBox2.Text);
textBox2.Text = "";
}
} private void buttonsc11_Click(object sender, EventArgs e)
{
if(listBox2.SelectedItems.Count == 0)
{
MessageBox.Show("请选择要删除的项目");
}
else
{
listBox2.Items.Remove(listBox2.SelectedItem);
}
} private void button1_Click(object sender, EventArgs e)
{
int[] values1 = new int[this.listBox1.Items.Count];
for (int i = 0; i < this.listBox1.Items.Count - 1; i++)
{
int values = Convert.ToInt32(this.listBox1.Items[i].ToString().Trim());
values1[i] = values;
}
int[] values11 = new int[this.listBox2.Items.Count];
for (int i = 0; i < this.listBox2.Items.Count - 1; i++)
{
int values = Convert.ToInt32(this.listBox2.Items[i].ToString().Trim());
values11[i] = values;
}
if (values1.Length != values11.Length)
{
MessageBox.Show("输入的成绩与学分个数不相符,请核对");
}
else
{
for (int i = 0; i < values1.Length; i++) ;
{
int a = 0;
int b = values1[a];
if (b < 60)
{
b = 59;
}
else
{
Double[] scor; switch (b)
{
case 59:
scor[a] = 0.00; break;
case 60:
scor[a] = 1.00; break;
case 61:
case 62:
case 63:
scor[a] = 1.33; break;
case 64:
case 65:
case 66:
scor[a] = 1.67; break;
case 67:
case 68:
case 69:
scor[a] = 2.00; break;
case 70:
case 71:
case 72:
case 73:
scor[a] = 2.33; break;
case 74:
case 75:
case 76:
scor[a] = 2.67; break;
case 77:
case 78:
case 79:
scor[a] = 3.00; break;
case 80:
case 81:
case 82:
case 83:
scor[a] = 3.33; break;
case 84:
case 85:
case 86:
scor[a] = 3.67; break;
case 87:
case 88:
case 89:
scor[a] = 4.00; break;
case 90:
case 91:
case 92:
case 93:
case 94:
scor[a] = 4.33; break;
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
scor[a] = 4.67; break;
}
sum1 += scor[a] * values11[a];
sum2 += values11[a];
}
a++;
}
gpa = sum1 / sum2;
label1.Text = gpa.ToString();
} }
}
}
额。。 全发过来了
double[] scor = new double[SIZE]; //SIZE 常量
//如果SIZE不能确定,则可以考虑用List,ArrayList之类的动态创建
List<double> scor = new List<double>(); // 这样就行
//不过我看了一下你的逻辑,定义一个Double够用了吧?
double scor = 0.0;
else
{
for (int i = 0; i < values1.Length; i++) ;
{
int a = 0;
int b = values1[a];
if (b < 60)
{
b = 59;
}
else
{
List<double> scor = new List<double>(); switch (b)
{
case 59:
scor.Add(0.00); break;
case 60:
scor.Add(1.00); break;
case 61:
case 62:
case 63:
scor.Add(1.33); break;
case 64:
case 65:
case 66:
scor.Add(1.67); break;
case 67:
case 68:
case 69:
scor.Add(2.00); break;
case 70:
case 71:
case 72:
case 73:
scor.Add(2.33); break;
case 74:
case 75:
case 76:
scor.Add(2.67); break;
case 77:
case 78:
case 79:
scor.Add(3.00); break;
case 80:
case 81:
case 82:
case 83:
scor.Add(3.33); break;
case 84:
case 85:
case 86:
scor.Add(3.67); break;
case 87:
case 88:
case 89:
scor.Add(4.00); break;
case 90:
case 91:
case 92:
case 93:
case 94:
scor.Add(4.33); break;
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
scor.Add(4.67); break;
}
sum1 += scor[a] * values11[a];
sum2 += values11[a];
}
a++;
}
gpa = sum1 / sum2;
label1.Text = gpa.ToString();
}
List<double> scorList = new List<double>();
double scor = 0.00;
两个需要一个List就够了。
在整个程序进行运算完之后 怎样对之前的数组清空。。
就是在 gpa = sum1 / sum2;
label1.Text = gpa.ToString();
之后
要不程序运算完之后 要想进行下次运算 用户只能关闭程序再打开 否则之前的数据会干扰结果
刚刚试过了
List有Clear()的方法,数组的全部置0就行了。