📄 ycl.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// ycl 的摘要说明
/// </summary>
public class ycl
{
public ycl()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void get_GDITOGDP(DataSet ds,DataSet dt)
{
int Count_R = ds.Tables[0].Rows.Count;//ds的行数
int Count_C = ds.Tables[0].Columns.Count;//ds的列数
int dt_Count_C = dt.Tables[0].Columns.Count;//读取dt的列数
//定义数组
float[,] values = new float[Count_R, Count_C];
float[,] temp = new float[Count_R, Count_C];
//定义变量
int i, j;
//读取ds数据集里的数据到values数组中
for (i = 0; i < Count_R; i++)
for (j = 0; j < Count_C; j++)
values[i, j] = Convert.ToSingle(ds.Tables[0].Rows[i][j].ToString());
for (i = 0; i<Count_R; i++)
temp[i, 0] = values[i, 0];
for (j = 1; j < Count_C; j++)
temp[0, j] = Convert.ToSingle(100);
for(i=1;i<Count_R;i++)
for (j = 1; j < Count_C; j++)
temp[i, j] = Convert.ToSingle(values[i, j] / values[i-1, j] * temp[i-1,j]);
//把计算后的结果,写入到dt数据集中
for (i = 0; i<Count_R; i++)
{
DataRow newRow = dt.Tables[dt.Tables[0].ToString()].NewRow();
for(j=0;j< Count_C;j++)
newRow[j] = temp[i,j];
dt.Tables[dt.Tables[0].ToString()].Rows.Add(newRow);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -