阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include include
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
【C++程序】
include < stdio. h >
include < string. h >
define Max 1000
class Bank
{
int index;
char date [Max] [10]; // 记录交易日
iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱
int rest[ Max]; // 记录每次交易后余额
static iht sum; // 账户累计余额
public:
Bank( ) {index =0;}
void deposit( char d[ ] , int m) //存入交易
{
strcpy ( date [ index ], d);
amount[ index] = m;
(1);
rest[ index] = sum;
index++;
}
void withdraw (char d[ ], int m) //取出交易
{
strcpy( date[ index] ,d);
(2);
(3);
rest[ index] = sum;
index++;
}
void display( );
};
int Bank:: sum = 0;
void Bank:: display ( ) //输出流水
{
int i;
printf("日期 存入 取出 余额\n");
for (4)
{
printf(" %8s" ,date[i] );
if (5)
printf(" %6d" , -amount[i] );
else
printf( "%6d ",amount[i] );
printf( "% 6d\n" ,rest[i] );
} }
void main( )
{
Bank object;
object. deposit ( "2006.2.5", 1 00 );
object. deposit( "2006.3.2" , 200);
object. withdraw( "2006.4.1", 50);
object. withdraw( "2006.4.5", 80);
object. display ( );
}
本程序的执行结果如下:
日期 存入 取出 余额 2006.2.5 100 100
2006.3.2 200 300
2006.4.1 50 250
2006.4.5 80 170
参考答案: