西工大c语言实验100题08文档格式.docx
《西工大c语言实验100题08文档格式.docx》由会员分享,可在线阅读,更多相关《西工大c语言实验100题08文档格式.docx(19页珍藏版)》请在冰点文库上搜索。
![西工大c语言实验100题08文档格式.docx](https://file1.bingdoc.com/fileroot1/2023-5/6/1e1bf565-782c-46da-8288-c6154287ff61/1e1bf565-782c-46da-8288-c6154287ff611.gif)
value=move(value,n);
%u\n"
value);
unsignedmove(unsignedvalue,intn)
{
unsignedt;
if(n==0)returnvalue;
if(n>
0){
t=~(~0<
<
t=t&
value;
t=t<
(32-n);
value=value>
n;
value=value|t;
}
else{
n=-n;
t=~(~0>
t=t>
value=value<
returnvalue;
T1301
stdlib.h>
inti=0,j=0,k=0;
FILE*p;
charch;
p=fopen("
T1301.TXT"
"
r"
if(p==NULL){
exit(0);
while(!
feof(p)){
ch=fgetc(p);
if(ch=='
i'
){
f'
i++;
w'
h'
l'
e'
j++;
o'
r'
k++;
fclose(p);
if=%d,while=%d,for=%d\n"
i,j,k);
T1304
structstu{
intno;
charname[12];
intage;
ints[7];
intt;
}a[100],b;
FILE*p2;
inti,j,k,n=0,i1;
p2=fopen("
T1304.db"
wb"
//从文件中读取数据到a[100]
for(i=0;
i<
100;
i++){
n++;
for(i1=0;
i1<
=12;
i1++){
a[i].name[i1]='
\0'
;
}
scanf("
%d%s%d"
a[i].no,a[i].name,&
a[i].age);
a[i].t=0;
for(j=0;
j<
7;
j++){
scanf("
%d"
a[i].s[j]);
a[i].t=a[i].s[j]+a[i].t;
//对a[100]进行排序
99;
k=i;
for(j=i+1;
if(a[k].t<
a[j].t){
k=j;
}
if(k!
=i){
b=a[i];
a[i]=a[k];
a[k]=b;
//将a[100]输入到文件中
fwrite(&
a[i],sizeof(structstu),1,p2);
%d\n"
n);
fclose(p2);
SXL02
FILE*in,*out;
inti=1;
in=fopen("
SXL02a.TXT"
out=fopen("
SXL02b.txt"
w"
if(!
feof(in)){
fprintf(out,"
%04d"
i);
if((ch=fgetc(in))=='
\n'
i++;
fputc('
out);
fprintf(out,"
else{
if(ch!
=EOF){
fputc(ch,out);
fclose(in);
fclose(out);
SXL03
string.h>
structstu{
intno;
charname[12];
intscore;
}a,b;
intn,i;
SXL03.db"
w+"
a.no,a.name,&
a.score);
a,sizeof(structstu),1,p);
rewind(p);
fread(&
b,sizeof(structstu),1,p);
if(a.score<
=b.score){
a.no=b.no;
strcpy(a.name,b.name);
a.score=b.score;
%d%s%d\n"
a.no,a.name,a.score);
SXL04
inti=1,j=1;
FILE*p1,*p2;
chara,b;
p1=fopen("
SXL04a.TXT"
SXL04b.TXT"
feof(p1)&
&
!
feof(p2)){
a=fgetc(p1);
b=fgetc(p2);
if(a=='
i++,j=1;
if(a!
=b){
printf("
行=%d,列=%d\n"
i,j);
j++;
fclose(p1);
IE01
inti,j,k,flage,n,m,b;
intrunnian(int);
%d%d%d"
n,&
m,&
b);
i=b,j=m,k=n;
flage=runnian(i);
if(j==12&
k==31){
i++;
j=1;
k=1;
if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){
if(k<
31){
k++;
else{
j++;
k=1;
if(j==2&
flage){
if(k<
29){
k++;
}
else{
k=1;
j++;
if(j==2&
flage){
if(k<
28){
}
else{
30){
datefollowing%d-%d-%dis%d-%d-%d\n"
n,m,b,k,j,i);
intrunnian(inty)
if(y%4==0&
y%100!
=0||y%400==0){
return1;
return0;
IE02
math.h>
inti,j,k=0,n=0;
%d%d"
i,&
j);
while(j!
=0){
k=k+j%10*pow(i,n);
j=j/10;
k);
IE03
inti,k=0;
if(i<
1)printf("
error\n"
while(i!
=1){
if(i%2){
i=3*i+1;
i=i/2;
k++;
if(k==1){
%d"
printf("
\nsteps=%d\n"
IE04
chara[500];
intreplace(char*);
gets(a);
n=replace(a);
puts(a);
n=%d\n"
intreplace(char*p)
intn=0;
while(*p!
='
if(*p=='
'
*p='
-'
n++;
p++;
returnn;
IE05
structhumble
{longdata;
structhumble*next;
}a[5842];
longmin(longa,longb,longc,longd)
a=a<
b?
a:
b;
c?
c;
d?
d;
returna;
voidinsert(structhumble*p,structhumble*head)
inti=0;
if(head->
next==NULL){
head->
next=p;
p->
next=NULL;
return;
while(head->
next!
=NULL){
if(head->
next->
data>
p->
data){
p->
next=head->
next;
head->
return;
head=head->
head->
p->
inti,n;
longm;
structhumble*p1,*p2,*p3,*p4,*pm;
a[0].data=1,a[0].next=&
a[1];
a[1].data=2,a[1].next=&
a[2];
a[2].data=3,a[2].next=&
a[3];
a[3].data=5,a[3].next=&
a[4];
a[4].data=7,a[4].next=NULL;
p1=p2=p3=p4=&
for(i=5;
5842;
m=min(2*p1->
data,3*p2->
data,5*p3->
data,7*p4->
data);
if(m==2*p1->
data)pm=p1,p1=p1->
if(m==3*p2->
data)pm=p2,p2=p2->
if(m==5*p3->
data)pm=p3,p3=p3->
if(m==7*p4->
data)pm=p4,p4=p4->
a[i].data=m;
insert(&
a[i],pm);
pm=&
a[0];
n-1;
i++,pm=pm->
next);
%ld\n"
pm->