【实(bing)用(wu)工(luan)具(yong)】根据数组来判断使用内存(然而竞赛用不了2333)

{

===Program by double8fun==

===Instuction==

输入文件 in.txt
程序输出 result.txt

输入文件格式:
第1行         一个n 表示n个数组
第2->n+1行    一行一个Di 表示第i个数组的维数
第n+2->2n+1行 一行一个Si 表示第i个数组的数据类型
第2n+2->3n+1行    一行n个Rj 表示第i个数组的第j个维度的左右边界之差


样例输入1:
====in.txt====
1
2
int64
99 99
==============
a1:array[1..100,1..100] of int64;
==============


样例输入2:
====in.txt====
2
1
2
longint
int64
999
99 99
==============
a1:array[1..1000] of longint;
a2:array[1..100,1..100] of int64;
==============

Si的集合:
real,
single,
double,
extended,
comp,
shortint,
integer,
longint,
byte,
word,
longword,
Int64,  
QWord 
}

const
    p = 1048576; 
    maxn = 10;
var
    ans:extended;
    zj:array[1..maxn] of 1..10;
    dim:array[1..maxn] of 1..5;
    si:array[1..maxn] of int64;
    i,j,n,siz,ki,kj,tmp:longint;
    s:string;

begin
    assign(input,'in.txt');reset(input);
    assign(output,'result.txt');rewrite(output);
    readln(n);
    for i:=1 to n do begin
        readln(dim[i]);
    end;
    for i:=1 to n do begin
        readln(s);
        if s='single' then zj[i]:=6;
        if  s='double' then zj[i]:=4;
        if  s='extended'then zj[i]:=8;
        if  s='comp' then zj[i]:=10;
        if  s='shortint' then zj[i]:=8;
        if  s='integer' then zj[i]:=1;
        if  s='longint' then zj[i]:=2;
        if  s='byte' then zj[i]:=4;
        if  s='word' then zj[i]:=1;
        if  s='longword' then zj[i]:=2;
        if  s='int64' then zj[i]:=8;
        if  s='qword' then zj[i]:=8; 
    end;
    for i:=1 to n do begin
        siz:=1;
        for j:=1 to dim[i] do begin 
            read(ki);
            inc(ki);
            siz:=siz*ki;
        end;
        si[i]:=siz;
    end;
    ans:=0;
    for i:=1 to n do 
        ans:=(ans+si[i]*zj[i])/p;
    writeln('MB in total:',ans:0:5,'MB');
    close(input);
    close(output);
end.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值