#include<stdio.h>
#include<stdlib.h>
main()
{
FILE *fp;
char a[10],ch;
scanf("%s",a);
if((fp=fopen(a,"w"))==NULL)
exit(0);
ch=getchar();
ch=getchar();
while(ch!='#')
{
fputc(ch,fp);
ch=getchar();
}
putchar(10);
fclose(fp);
}
#include<stdio.h>
#include<stdlib.h>
main()
{
FILE *in,*out;
char a[10],b[10];
scanf("%s",a);
scanf("%s",b);
if((in=fopen(a,"r"))==NULL)
exit(0);
if((out=fopen(b,"w"))==NULL)
exit(0);
while(!feof(in))
{
fputc(fgetc(in),out);
}
fclose(in);
fclose(out);
}
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *inputFile;
inputFile = fopen("data.bin", "rb");
if (!inputFile) {
fprintf(stderr, "Can't open bin file!");
exit(1);
}
fseek(inputFile, 0, SEEK_END);
long inputFileLength = ftell(inputFile);
printf("input file length: %ld\n", inputFileLength);
fseek(inputFile, 0, SEEK_SET);
fclose(inputFile);
return 0;
}
#include<stdio.h>
struct student
{
int num;
char name[20];
int score[3];
}stu[5];
main()
{
int i,j,all;
char a[3];
for(i=0;i<5;i++)
{
printf("the:%d\t",i+1);
scanf("%d%s",&stu[i].num,&stu[i].name);
scanf("%d%d%d",&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);}
for(i=0;i<5;i++)
{
printf("%d\t%s\t",stu[i].num,stu[i].name);
printf("%d\t%d\t%d\n",stu[i].score[0],stu[i].score[1],stu[i].score[2]);
}
for(i=0;i<3;i++)
{
a[i]=stu[0].score[i]+stu[1].score[i]+stu[2].score[i]+stu[3].score[i]+stu[4].score[i];
printf("%.2f",a[i]/3);
}
for(i=0;i<5;i++)
{
for(j=0;j<3;j++)
if(stu[i].score[j]<60)
all++;
if(all>1)
{
printf("%d\t",stu[i].num);
for(j=0;j<3;j++)
if(stu[i].score[j]<60)
printf("%d\t",stu[i].score[j]);
printf("\n");
}
}
for(i=0;i<5;i++)
{
all=0;
for(j=0;j<3;j++)
all+=stu[i].score[j];
if(all/3>=85&&all/3<=90)
printf("%d\t%s\n",stu[i].num,stu[i].name);
}
}
#include<stdio.h>
double fun(double x,int y)
{
if(y==1)
return(x);
else
return(x*fun(x,y-1));
}
main()
{
int y;
double x;
scanf("%d%lf",&y,&x);
printf("%d",fun(x,y));
}
#include<stdio.h>
struct student
{
int num;
int score;
}stu[5]={{1,68},{2,95},{3,76},{4,68},{5,97}};
int fun(int stu[5])
{
int i,all=0,low=100;
for(i=0;i<5;i++)
if(stu[i].score<low)
low=stu[i].score;
for(i=0;i<5;i++)
{
if(stu[i].score==low)
all++;
}
return(all);
}
main()
{
printf("%d",fun(stu));
}
#include<stdio.h>
main()
{
int i,j,k,l=0;
int a[3000],b;
for(i=1;i<5;i++)
for(j=1;j<5;j++)
if(i!=j)
for(k=1;k<5;k++)
if(i!=k&&j!=k)
{
{
a[l]=i*100+j*10+k;
l++;
}
}
b=l;
for(i=0;i<b;i++)
{
for(j=i+1;j<b;j++)
{
if(a[i]==a[j])
{
a[i]=0;
break;
}
}
}
for(i=0;i<b;i++)
if(a[i]!=0)
printf("%d\t",a[i]);
}
|