西工大C语言终极第八季修订版Word格式.docx
《西工大C语言终极第八季修订版Word格式.docx》由会员分享,可在线阅读,更多相关《西工大C语言终极第八季修订版Word格式.docx(23页珍藏版)》请在冰豆网上搜索。
if(top==NULL){top=rare=f;
else
{
rare->
next=f;
rare=f;
}
}
intmain()
Listlst;
inta,c;
charb[12];
Student*pp;
do
cin>
>
a;
if(a==0)break;
b>
c;
lst.push(a,b,c);
while
(1);
pp=lst.top;
while(pp!
=NULL)
cout<
<
pp->
t<
"
"
;
pp=pp->
next;
endl;
while(pp!
if(pp->
t!
=a)cout<
return0;
72
73
#include<
stdio.h>
stdlib.h>
voidcheng(chara[],charb[])
inti,j,ca,cb,*s;
ca=strlen(a);
cb=strlen(b);
s=(int*)malloc(sizeof(int)*(ca+cb));
for(i=0;
i<
ca+cb;
i++)s[i]=0;
ca;
i++)
for(j=0;
j<
cb;
j++)
s[i+j+1]+=(a[i]-'
0'
)*(b[j]-'
);
for(i=ca+cb-1;
i>
=0;
i--)
if(s[i]>
=10)
s[i-1]+=s[i]/10;
s[i]%=10;
i=0;
while(s[i]==0)i++;
for(;
i++)printf("
%d"
s[i]);
printf("
\n"
free(s);
chara[100],b[100];
gets(a),gets(b);
if(a[0]=='
-'
&
b[0]!
='
)
printf("
-"
cheng(&
a[1],b);
elseif(a[0]=='
b[0]=='
a[1],&
b[1]);
elseif(a[0]!
cheng(a,&
else
cheng(a,b);
return0;
74
75
intlen1,len2;
intre[105];
voidsub(chars1[],chars2[])
{
inti=0;
intj;
while
(1)
if(s1[i]=='
)
i++;
else
j=i;
break;
}
for(;
len2;
i++)
s1[i]=s1[i]-s2[i]+'
for(i=len2-1;
j;
if(s1[i]<
'
)
s1[i]+=10;
s1[i-1]--;
voidchu(chars1[],chars2[])
intp,i;
len1=strlen(s1);
len2=strlen(s2);
if(len1<
len2||(len1==len2&
strncmp(s1,s2,len2)<
0))
0\n"
return;
p=0;
re[p]=0;
while(strncmp(s1,s2,len2)>
=0)
sub(s1,s2);
re[p]++;
p++;
if(len1==len2)
s2[i+1]=s2[i];
s2[0]='
len2++;
s2[len2]='
\0'
i=0;
if(re[i]==0)
p;
re[i]);
}
intmain(void)
chars1[105];
chars2[105];
gets(s1),gets(s2);
if(s1[0]=='
s2[0]!
chu(&
s1[1],s2);
elseif(s1[0]=='
s2[0]=='
s1[1],&
s2[1]);
elseif(s1[0]!
chu(s1,&
chu(s1,s2);
76
#definemax(a,b)a>
b?
a:
b
#definemin(a,b)a>
b:
a
intsum[101];
voidjia(chara[],charb[])
intflag=0,i,len1,len2,lenmax,lenmin;
len1=strlen(a),len2=strlen(b);
lenmax=max(len1,len2),lenmin=min(len1,len2);
for(i=1;
=lenmax;
if(i<
=lenmin)
sum[lenmax-i]=a[len1-i]+b[len2-i]-'
+flag;
if(sum[lenmax-i]>
sum[lenmax-i]=sum[lenmax-i]-10;
flag=1;
elseflag=0;
else{
if(len1>
len2)
sum[lenmax-i]=a[len1-i]-'
if(sum[lenmax-i]>
sum[lenmax-i]=sum[lenmax-i]-10;
flag=1;
sum[lenmax-i]=b[len2-i]-'
if(flag==1)
1"
for(i=0;
lenmax;
sum[i]);
voidjian(chara[],charb[])
intflag=0,i;
=len1;
=len2)
if(a[len1-i]-b[len2-i]-flag>
=0)
sum[len1-i]=a[len1-i]-b[len2-i]-flag;
flag=0;
sum[len1-i]=a[len1-i]-b[len2-i]-flag+10;
if(a[len1-i]-flag-'
sum[len1-i]=a[len1-i]-flag-'
sum[len1-i]=a[len1-i]-flag+10-'
for(i=0;
len1&
sum[i]==0;
i++);
len1;
voidcompare(chara[],charb[])
if(len1>
strcmp(a,b)>
0))
jian(a,b);
elseif(strcmp(a,b)!
jian(b,a);
gets(a);
gets(b);
compare(b,&
a[1]);
jia(&
compare(a,&
jia(a,b);
77
chara[10];
intn,b=0,c[250]={0},i,j,x;
c[249]=1;
scanf("
%s%d"
a,&
n);
a[i]!
if(a[i]=='
.'
x=i;
continue;
b=b*10+a[i]-'
x=i-x-1;
for(i=1;
n+1;
for(j=0;
250;
c[j]*=b;
for(j=249;
j>
j--)
if(c[j]>
c[j-1]+=c[j]/10;
c[j]%=10;
if(x==0)
c[i]==0;
for(;
c[i]);
0."
for(i=250-n*x;
250-n*x;
."
78
79
80
81.大数减法
compare(&
b[1],&
jia(a,&
compare(a,b);
82
83
84
85