日期:2014-05-19  浏览次数:20865 次

哪位高手有兴趣把这段C++转成C# 万分感谢了
//   每月还款金额
double   dMonthMoney   =   m_dMonthMoneyGive;

//   还款月数
int   monthNum   =   m_nMonthNum;

if(m_nMoneyGiveType   ==   0)
{
if(monthNum   <=   0)
{
MessageBox( "[还款月数]输入不正确 ");
CEdit*   pWnd   =   (CEdit*)   GetDlgItem(IDC_MONTH_NUM);
pWnd-> SetFocus();
pWnd-> SetSel(0,   -1);
return;
}

dMonthMoney   =   GetMonthMoneyGive(m_lTotalMoney,   monthNum,   a);
}
else
{
monthNum   =   GetMonthNum(m_lTotalMoney,   dMonthMoney,   a);
}

if(monthNum   <   1)
{
return;
}

//   每月利息
double*   X   =   new   double[monthNum];

//   每月末剩余本金
double*   Y   =   new   double[monthNum];



X[0]   =   m_lTotalMoney   *   a;
Y[0]   =   m_lTotalMoney   -   (dMonthMoney   -   X[0]);

double   XTotalTmp   =   X[0];
int   nPrevGiveNum   =   0;

for(int   i   =   1;   i   <   monthNum;   ++   i)
{
X[i]   =   Y[i   -   1]   *   a;
XTotalTmp   +=   X[i];

Y[i]   =   m_lTotalMoney   -   ((   i   +   1)   *   dMonthMoney   -   XTotalTmp);
}

//   设置结算结果
m_dTotalMoneyGive   =   dMonthMoney   *   monthNum;
m_dMoneyInterestGive   =   0;
m_dBaseMoneyGive   =   m_lTotalMoney   -   Y[monthNum   -   1]   ;
m_dBaseMoneyLeave   =   Y[monthNum   -   1];
m_dMonthMoneyGive   =   dMonthMoney;
m_nMonthNum   =   monthNum;

for(int   k   =   0;   k   <   monthNum;   ++   k)
{
m_dMoneyInterestGive   +=   X[k];
}

if(X   !=   NULL)
{
delete   []X;
X   =   NULL;
}

if(Y   !=   NULL)
{
delete   []Y;
Y   =   NULL;
}

SetCursor(hCursorSrc);

UpdateData(FALSE);

}

double   TryGetMonth(long   totalMoney,   int   monthNum,  
  double   dInterestRate,   double   dPrevMoneyGive,   int   nPrevMoneyGiveMonth,   double   monthMoney)
{
double   dReturn   =   0;

bool   isPrevGive   =   dPrevMoneyGive   >   0;

//   每月利息
double*   X   =   new   double[monthNum];

//   每月末剩余本金
double*   Y   =   new   double[monthNum];

X[0]   =   totalMoney   *   dInterestRate;
Y[0]   =   totalMoney   -   (monthMoney   -   X[0]);

double   XTotalTmp   =   X[0];
int   nPrevGiveNum   =   0;
for(int   i   =   1;   i   <   monthNum;   ++   i)
{
X[i]   =   Y[i   -   1]   *   dInterestRate;
XTotalTmp   +=   X[i];

bool   isPrevCal   =   i   %   nPrevMoneyGiveMonth   >   0;
nPrevGiveNum   =   i   /   nPrevMoneyGiveMonth;