首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

模拟电信计费系统里的计算资费的函数有关问题

2012-01-05 
模拟电信计费系统里的计算资费的函数问题/函数功能:计算每个通话记录的话费//函数参数:Charge型指针ptc,表

模拟电信计费系统里的计算资费的函数问题
/函数功能:计算每个通话记录的话费
//函数参数:Charge型指针ptc,表示通话记录对象数组的首地址
//Rate型指针ptr,表示费率对象数组的首地址
//整型totalCharge,表示通话记录总数
//整形totalRate,表示费率总数
//函数返回值:整型,0表示异常退出;1表示正常退出
int ComputeExp(Charge *ptc,Rate *ptr,int totalCharge,int totalRate)
{
if(ptc==NULL||totalCharge==0)
{
cout<<"没有通话记录,无法计算!"<<endl;
return 0;
}
for(int i=0;i<totalCharge;i++)
{
int time=0;
float fl=0;
float temp=0.0;
time=(ptc+i)->Time/60;
if((ptc+i)->Time%60>=0)
time++;
(ptc+i)->ComputeSty();
if((ptc+i)->CallStyle==0)//计算本地通话费
{
if(time<=3)
temp=0.5;
else
{
int n=time/3;
int m=time%3;
for(int j=0;j<n;j++)
{
temp=temp+0.5+float(j)*0.2;
}
if(m!=0)
temp=temp+0.5+float(j)*0.2;
}
(ptc+i)->Expense=temp;
}
else//计算长途话费
{
for(int x=0;strcmp((ptc+i)->BCode,(ptr+x)->Code)&&x<totalRate;x++)
{
fl=(ptr+x)->rate;
temp=float(time)*fl;
(ptc+i)->Expense=temp;
}
}
}
cout<<"话费计算结束!"<<endl;
return 1;
}
能帮我看下错在哪儿吗?运行这个函数的时候老是出现不能写入的错误

[解决办法]
一句一句调试把

热点排行