[转]进制转换_C++

本文由晨之子发表在破碎·永恒

Code:

#include <cstdio>
#define MAXLEN 1000

class Num
{
protected:
          int num[MAXLEN];
          int base;
          int length;
public:
       Num();
       ~Num();
       void converse(int new_base);
       void init_base();
       void init_num();
       void print();
};

Num::Num()
{
    memset(num,0,sizeof(num));
    length=0;
    base=0;
}

Num::~Num()
{
}

void Num::init_base()
{
     scanf(“%d”,&base);
     return;
}

void Num::init_num()
{
     char ch;
     int i;
     length=0;
     memset(num,0,sizeof(num));
     scanf(“%c”,&ch);
     while (ch!=’\n’)
     {
           while (ch==’ ‘) scanf(“%c”,&ch);
           for (i=0;i<62;i++) if (ch==digits[i]) num[length]=i;
           length++;
           scanf(“%c”,&ch);
     }
     for (i=0;i<length/2;i++)
     {
         num[i]=num[i]+num[length-i-1];
         num[length-i-1]=num[i]-num[length-i-1];
         num[i]=num[i]-num[length-i-1];
     }
     return;
}

void Num::print()
{
     int i;
     printf(“%d “,base);
     for (i=length-1;i>=0;i–) printf(“%c”,digits[num[i]]);
     printf(“\n”);
     return;
}

void Num::converse(int new_base)
{
     int new_num[MAXLEN+1];
     int power[MAXLEN+1];
     int new_length;
     int i;
     memset(power,0,sizeof(power));
     memset(new_num,0,sizeof(new_num));
     power[0]=1;
     new_num[0]+=num[0]*power[0];
     for (i=0;i<MAXLEN;i++)
     if (new_num[i]>=new_base)
     {
         new_num[i+1]+=new_num[i]/new_base;
         new_num[i]%=new_base;
     }
     for (i=1;i<length;i++)
     {
         int temp[MAXLEN+1];
         int j;
         memset(temp,0,sizeof(temp));
         for (j=0;j<MAXLEN;j++) power[j]*=base;
         for (j=0;j<MAXLEN;j++)
         if (power[j]>=new_base)
         {
             power[j+1]+=power[j]/new_base;
             power[j]%=new_base;
         }
         for (j=0;j<MAXLEN;j++)
         temp[j]=power[j]*num[i];
         for (j=0;j<MAXLEN;j++)
         if (temp[j]>=new_base)
         {
             temp[j+1]+=temp[j]/new_base;
             temp[j]%=new_base;
         }
         for (j=0;j<MAXLEN;j++)
         {
             new_num[j]+=temp[j];
             if (new_num[j]>=new_base)
             {
                 new_num[j+1]+=new_num[j]/new_base;
                 new_num[j]%=new_base;
             }
         }
     }
     new_length=MAXLEN;
     while ((new_num[new_length-1]==0)&&(new_length>1)) new_length–;
     for (i=0;i<MAXLEN;i++)
     num[i]=new_num[i];
     base=new_base;
     length=new_length;
     return;
}

Free Pascal程序运行错误

Run time errors
Free Pascal生成的应用程序也许会生成一些运行错误,当应用程序发现某个确定的异常情况时,这里列出了错误代码,并且解释产生的原因.

1 Invalid function number
  错误的功能代码
   尝试错误的操作系统调用.
2 File not found
  文件未找到
   程序试图删除(erase),重命名( rename),打开(open)一个不存在的文件.
3 Path not found
  目录未发现
   目录不存在或是错误.也有可能是访问一个不存在的文件.
4 Too many open files
  打开太多的文件
   当前你的程序当前打开的文件太多咯.超过了操作系统允许打开的最多文件数.
5 File access denied
  文件访问拒绝
   访问文件拒绝.引起这个错误可能是下面几个原因:
    试图写一个只读文件,或者实际上是一个目录.
    文件正在为其他程序所使用.
    试图建立一个目录中已经存在的文件名的文件.
    试图从一个只能写的文件中读数据.
    试图从一个只能读的文件中写数据.
    试图移除一个不存在的文件或目录.
    不允许访问这个文件或者目录.
6 Invalid file handle
  错误的文件句柄
    表示你的文件表示府已经失效; 指出你的内存已经混乱.
12 Invalid file access code
  错误的文件访问代码
   reset 或 rewrite 使用一个错误的文件模式值.
15 Invalid drive number
  错误的驱动器数字
    Getdir或者ChDir函数所使用数字指向了一个不存在的磁盘.
16 Cannot remove current directory
  不能移动当前目录
    试图移除的目录是当前活动目录..
17 Cannot rename across drives
   不能跨越驱动器更改文件名
    你不能重命名一个文件,它可能在另一个磁盘或分区结束.
100 Disk read error
  磁盘读错误
    从磁盘读数据时错误.具有代表性的是你读文件超过了文件结尾.
101 Disk write error
  磁盘写错误
   磁盘已经满咯,可是你还试图写入数据..
102 File not assigned
  文件未曾建立关联
    使用Reset, Rewrite, Append, Rename和 Erase 之前你必须已经将文件标识符与磁盘文件建立关联.
103 File not open
  文件未打开
   在使用 Close, Read, Write, Seek, EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite 之前未打开文件.
104 File not open for input
  文件不能打开读数据
   在使用 Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln 之前文件未使用Reset打开.
105 File not open for output
  文件不能打开写数据
    使用write之前未使用Rewrite打开.
106 Invalid numeric format
  错误的数字格式
    从标准输入(Text文件)中预期得到的数字格式不对.
150 Disk is write-protected
  磁盘写保护
(Critical error)=临界误差
151 Bad drive request struct length
(Critical error)
152 Drive not ready
驱动器未准备好
(Critical error)
154 CRC error in data
数据CRC校检错误
(Critical error)
156 Disk seek error
磁盘寻道错误
(Critical error)
157 Unknown media type
不明的媒体类型
(Critical error)
158 Sector Not Found
磁盘扇区错误
(Critical error)
159 Printer out of paper
打印超过纸张
(Critical error)
160 Device write fault
设备写错误
(Critical error)
161 Device read fault
设备读错误
(Critical error)
162 Hardware failure
硬件失灵
(Critical error)
200 Division by zero
被除数为0.
201 Range check error
 如果你便以你的程序时设置了方位检查,原因有可能是:
 数组访问超过了声明的范围.
 试图给一个变量赋值超过其范围(例如枚举类型).

202 Stack overflow error
栈溢出
栈增长超过了最大值 (in which case the size of local variables should be reduced to avoid this error), or the stack has become corrupt. 只有当栈检查时才出现该错误.
203 Heap overflow error
堆溢出
堆增长超过了上界. This is caused when trying to allocate memory exlicitly with New, GetMem or ReallocMem, or when a class or object instance is created and no memory is left. Please note that, by default, Free Pascal provides a growing heap, i.e. the heap will try to allocate more memory if needed. However, if the heap has reached the maximum size allowed by the operating system or hardware, then you will get this error.
204 Invalid pointer operation
错误的指针操作
使用 Dispose or Freemem 时使用错误的指针 (特别的, Nil)
205 Floating point overflow
浮点数上溢
你试图使用或产生一个太大实数.
206 Floating point underflow
你试图使用或产生一个太小实数.
207 Invalid floating point operation
错误的浮点数操作
可能是你开平方根或者对数时使用负数.
210 Object not initialized
对象位初始化
When compiled with range checking on, a program will report this error if you call a virtual method without having called istr constructor.
211 Call to abstract method
Your program tried to execute an abstract virtual method. Abstract methods should be overridden, and the overriding method should be called.
212 Stream registration error
This occurs when an invalid type is registered in the objects unit.
213 Collection index out of range
You are trying to access a collection item with an invalid index (objects unit).
214 Collection overflow error
The collection has reached its maximal size, and you are trying to add another element (objects unit).
215 Arithmetic overflow error
This error is reported when the result of an arithmetic operation is outside of its supported range. Contrary to Turbo Pascal, this error is only reported for 32-bit or 64-bit arithmetic overflows. This is due to the fact that everything is converted to 32-bit or 64-bit before doing the actual arithmetic operation.
216 General Protection fault
The application tried to access invalid memory space. This can be caused by several problems:
Deferencing a nil pointer
Trying to access memory which is out of bounds (for example, calling move with an invalid length).

217 Unhandled exception occurred
An exception occurred, and there was no exception handler present. The sysutils unit installs a default exception handler which catches all excpetions and exits gracefully.
219 Invalid typecast
Thrown when an invalid typecast is attempted on a class using the as operator. This error is also thrown when an object or class is typecast to an invalid class or object and a virtual method of that class or object is called. This last error is only detected if the -CR compiler option is used.

227 Assertion failed error
An assertion failed, and no AssertErrorProc procedural variable was installed.

发现自己的英文水平实在有待提高啊

大榕树上的点点

第一节

似乎,曾经有过这么句歌词:谁为谁心疼;换成等待也很好

忘忧草 – 周华健
让软弱的我们懂得残忍
狠狠面对人生每次寒冷
依依不舍的爱过的人
往往有缘没有份
谁把谁真的当真
谁为谁心疼
谁是唯一谁的人
伤痕累累的天真的灵魂
早已不承认还有什么神
美丽的人生
善良的人
心痛心酸心事太微不足道
来来往往的你我遇到
相识不如相望淡淡一笑
忘忧草忘了就好
梦里知多少
某天涯海角
某个小岛
某年某月某日某一次拥抱
轻轻河畔草

很喜欢这首歌,略微伤悲的音乐,让人总是很神往(迷糊吧,*_*#)。躺在床上听音乐的感觉很舒服~
喜欢睡着的感觉,不必后悔昨天,不必不必担心明天,只要静静的在被子里,躺着,躺着。心想大概睡着的女生梦里留露的笑容应该很可爱,只是没看过^_@!
淡淡的花自是独自散发着清香,镜花何在?以前刚上网的时候,总是起镜花水月这个名字,QQ也是,后来改了,重复的太多……后来改成了这个ID,独创!不过QQ上搜索,竟然搜不到~~555~~~
以前以为什么都如这镜中花,水中月。但后来发现,其实像网络这种很那个的空虚的世界,也有真实的,像我这段文字,嘿嘿
只是现在发现有很多事无法忘却,却又无法后悔,这个网名似乎更符合我的心情,估计会像邓小平的100年不变!

第二节

 一直很嫉妒每一个人
以为老天最不在乎我
但是,童年的幼稚渐渐离我而去
我突然发现,原来上帝对每个人都很公平
失败.原来也不是那么可怕
可怕的是一个人的心已经死去

突然发觉心好疼
感觉周围是那么远
自己孤立无助
失去了目标是可怕的
没有了同志是灾难
我惆怅,徘徊……
回忆过去那无忧的生活
发现其实人长大
也是一种痛苦
却也有一分幸福
只有努力,方能面对明天

第三节

残存记忆
金乌东起,阳光布洒大地.
朦胧睁开惺忪的睡眼,懒洋洋的赖在暖烘烘的被子里.
新的一天又降临,空气中飘荡一种清新
但是,重复的却是历经千百遍的事,心中不由多了几丝阴影,淡忘,是时间的杰作
却磨平不了心中的旧伤,残存的,谁也不知道,除了半夜惊魂,
期待是梦中的幻想,等待我没有其他路.
期盼,是绝望的呼唤,惟有,梦中绽现的浅笑是永恒

曾经几何DRS是我最爱,可是现在我却只能眼睁睁的看着它日薄西山,我的心情,我的一步步成长…伴随着AFY的离去渐渐消失…怀念当初啊

bolg建立

经过千辛万苦我的blog终于建立咯
首先要感谢exblog team提供了这么好的blog程序
特别感谢www.21windows.com提供的免费50Mphp空间,15M MySQL空间啊
感谢老师提供手机让我在信息产业部备案,虽然还没有批下来
开始准备将原来的日志移过来咯!可能要花些功夫,不过也不是太多

不喜欢别的blog
因为不是自己的东西都不好处理
而且模板也不是很喜欢
最重要不是自己完全拥有它
很久咯
曾经看过Q-zone
很垃圾的,不知道腾讯是不是想赚钱想疯咯
没有几个是可以免费的
QQ还有一堆广告
要不是这么多朋友都用QQ啊
我都不想用那个咯,又特耗资源
越来越讨厌广告咯,可是如果没有广告,就没有免费咯
像google的还比较好,清新
自己弄咯一个新的免费空间,以后再去买一个吧,现在没有钱
exBlog免费的,模板也很好
我不要大而全,但是要好

为了将来想买个空间,可是目前偶还是学生,没有钱啊.只有等到大学再说

生活是一种很有趣的游戏,但却不完全是,要面对不容易
我痛苦的喜欢着,无奈的厌倦着

初赛成绩出来咯
我和龙都过咯,其他应该也没有问题吧
写这个时,我正在上传文件,以后就离开这里咯
也许这是最后的以此写咯

不知道有没有注销空间功能啊,我是比较爱干净的,不想浪费资源,注销了blogcn就好咯