高分求编程题程序(C语言)

1,完成一个数据文件(文本文件和二进制文件)拆分和组装程序:如果文件是5.3MB,拆成5个1MB大小的文件和1个0.3MB大小的文件;将拆分后的程序拷贝到另一个目录,并组装起来。比较和原文件有何区别!
2.完成一个压缩文件和解压文件实用程序:有一个文本文件,其内容是由英文大小写字母(A-Z,a-z)和数字(0-9)组成。采用如下压缩算法:原文内容是采用ASCII码编码,每个字符占八位,请将英文大小写字母(A-Z.a-z)和数字(0-9)用6位编码(如000000b表示数字0,0001001b表示数字9,001010表示A,依次类推),压缩原文本文件的内容并编写压缩程序,还原压缩后的文本文件。
3.完成一个加密和解密程序。加密的方法是将原文依次和密钥做异或,解密的方法同加密方法。密钥的长度为6-128个字符长!
4.你的C语言参考书上肯定有N!(N阶乘)的程序吧?输入书上的代码(采用循环和递归两种方法),然后输入几个自然数5、10、20、40、100、1000、10000查看结果是否正确?用高等数学中的方法来确定n!有多少位。判断程序的结果是否正确(位数不对,结果肯定不对).如果书上的程序有问题,请设计一个正确求解n!的程序!
5.输入中文表示的钱的多少,用数字显示出来。例如:一块八、一元八角、一块八毛均表示为1.8.请尽量穷举所有的中文表示方法。

我要程序源代码,而且一定要对的,如果不对,分是不会给的。要是对了,加100,重赏之下必有勇夫,大家努力吧,先行谢过了~

哥们,你这些题目真是无聊死了,而且很不清楚。
1.怎么拆分一个文件?如果一个文件是5.30004MB该怎么拆?拆到B为止?组装是怎么组装?随机合并?
2.你的例子到底是二进制还是十六进制?为什么0是000000b?
3.输入是什么?文本文件?还是从终端输入?密匙是提前决定还是程序运行的时候决定?
4.这个还好。试着做做吧。
5.这个无聊到极点,要不要把全国各种方言的说法也都给你算上?
讲清楚了再提问,否则10000分也没人给你做。

这是第四题的,虽说答案没问题,一旦输入太大就会很慢。

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

struct digit{
char d;
struct digit *previous;
struct digit *next;
};

typedef struct digit Digit;

struct bigint{
Digit *head;
Digit *tail;
};

typedef struct bigint BigInt;

void display(BigInt b){
int c=0;
while(b.tail!=0){
printf("%d",b.tail->d);
c++;
b.tail=b.tail->previous;
}
printf("\n");
printf("%d digits in total.\n",c);
}

void free_memory(BigInt *b){
Digit *p;
while(b->head!=0){
p=b->head->next;
free(b->head);
b->head=p;
}
b->head=0;
b->tail=0;
}

BigInt copy(BigInt b){
BigInt b2={0,0};
Digit *p,*q;
q=b.head;
while(q!=0){
if(b2.head==0){
b2.head=(Digit *)malloc(sizeof(Digit));
b2.head->next=0;
b2.head->previous=0;
p=b2.head;
}
else{
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
}
p->d=q->d;
q=q->next;
}
b2.tail=p;
return b2;
}

BigInt add(BigInt b1,BigInt b2){
char carry=0;
BigInt result={0,0};
Digit *p;
while(b1.head!=0&&b2.head!=0){
if(result.head==0){
result.head=(Digit *)malloc(sizeof(Digit));
result.head->next=0;
result.head->previous=0;
p=result.head;
}
else{
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
}
char c=b1.head->d+b2.head->d+carry;
if(c>=10){
carry=1;
c=c-10;
}
else carry=0;
p->d=c;
b1.head=b1.head->next;
b2.head=b2.head->next;
}
while(b1.head!=0){
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
p->d=b1.head->d+carry;
b1.head=b1.head->next;
carry=0;
}
while(b2.head!=0){
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
p->d=b2.head->d+carry;
b2.head=b2.head->next;
carry=0;
}
if(carry>0){
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
p->d=carry;
}
result.tail=p;
return result;
}

BigInt substract(BigInt b,char d){
BigInt result={0,0};
Digit *p;
char borrow=0,d2;
if(b.head->d>=d) d2=b.head->d-d;
else{
d2=b.head->d+10-d;
borrow=1;
}
while(b.head!=0){
if(result.head==0){
result.head=(Digit *)malloc(sizeof(Digit));
result.head->next=0;
result.head->previous=0;
result.head->d=d2;
p=result.head;
}
else{
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
if(b.head->d>=borrow){
p->d=b.head->d-borrow;
borrow=0;
}
else{
p->d=b.head->d+10-borrow;
borrow=1;
}
}
b.head=b.head->next;
}
if(p->d==0&&p!=result.head){
result.tail=p->previous;
result.tail->next=0;
free(p);
}
else result.tail=p;
return result;
}

BigInt multiply(BigInt b1,BigInt b2){
BigInt result,temp1,temp2={0,0},temp3,b;
result.head=(Digit *)malloc(sizeof(Digit));
result.head->previous=0;
result.head->next=0;
result.tail=result.head;
result.head->d=0;
char d1,d2,carry;
Digit *p;
b=copy(b1);
do{
temp1=b;
d1=b2.head->d;
b2.head=b2.head->next;
carry=0;
while(temp1.head!=0){
if(temp2.head==0){
temp2.head=(Digit *)malloc(sizeof(Digit));
temp2.head->next=0;
temp2.head->previous=0;
p=temp2.head;
}
else{
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
}
d2=temp1.head->d*d1+carry;
if(d2>=10){
carry=d2/10;
d2=d2%10;
}
else carry=0;
p->d=d2;
temp1.head=temp1.head->next;
}
if(carry>0){
p->next=(Digit *)malloc(sizeof(Digit));
p->next->previous=p;
p=p->next;
p->next=0;
p->d=carry;
}
temp3=result;
temp2.tail=p;
result=add(temp3,temp2);
free_memory(&temp2);
free_memory(&temp3);
Digit *d2=(Digit *)malloc(sizeof(Digit));
d2->previous=0;
d2->next=b.head;
b.head->previous=d2;
d2->d=0;
b.head=d2;
}while(b2.head!=0);
free_memory(&b);
return result;
}

BigInt factorial(BigInt b){
BigInt result,temp1,temp2=copy(b);
result.head=(Digit *)malloc(sizeof(Digit));
result.head->previous=0;
result.head->next=0;
result.tail=result.head;
result.head->d=1;
while(temp2.tail->d!=0){
temp1=result;
result=multiply(temp1,temp2);
free_memory(&temp1);
temp1=temp2;
temp2=substract(temp1,1);
free_memory(&temp1);
}
free_memory(&temp2);
return result;
}

int main(){
BigInt b={0,0};
Digit *p;
char c;
int i;
c=getchar();
while(c!='\n'){
if(!isdigit(c)){
printf("Invalid input.\n");
return 1;
}
if(b.tail==0){
b.tail=(Digit *)malloc(sizeof(Digit));
b.tail->next=0;
b.tail->previous=0;
p=b.tail;
}
else{
p->previous=(Digit *)malloc(sizeof(Digit));
p->previous->next=p;
p=p->previous;
p->previous=0;
}
i=c-'0';
p->d=(char)i;
c=getchar();
}
b.head=p;
BigInt r=factorial(b);
display(r);
free_memory(&r);
free_memory(&b);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-07-13
呵呵,楼上说的很对啊,而且要稍微花点时间呢~~以我的预算,40 RMB一题,我给你做
第2个回答  2009-07-16
楼主,谁要是帮你都做出来,我给他再加400分!
第3个回答  2009-07-13
money奉上 这个问题可行 这样的程序是要收费的 这点分也没有激情 看看有没有谁 闲的无聊 为你做吧
第4个回答  2009-07-13
200分远远不够。
200元还差不多。
第5个回答  2009-07-21
哇塞~

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网