高级语言程序设计课程第十次作业

这个作业属于哪个课程:https://edu.cnblogs.com/campus/fzu/2024C

这个作业要求在哪里: https://edu.cnblogs.com/campus/fzu/2024C/homework/13314

学号:092300125

姓名:张天荣

#include<stdio.h> 

int main(void){

    FILE* p=fopen("file1.txt","rt");
    FILE* h=fopen("file2.txt","wt");

    char c;
    while((c=fgetc(p))!=EOF)
        fputc(c,h);
    
    fclose(p);
    fclose(h);

    return 0;

}
#include<stdio.h> 

int main(void){

    FILE* p=fopen("file1.txt","rt");
    

    char c;
    int a=0;
    while((c=fgetc(p))!=EOF)
        a++;

    printf("%d",a);
    fclose(p);
    

    return 0;

}
#include<stdio.h> 

int main(void){

    FILE* p=fopen("file1.txt","rt");
    

    char c;
    
    while((c=fgetc(p))!=EOF)
        putchar(c);

    
    fclose(p);
    

    return 0;

}
#include<stdio.h> 

int main(void){

    FILE* p=fopen("file1.txt","rt");
    FILE* h=fopen("file2.txt","at");

    char c;
    
    while((c=fgetc(p))!=EOF)
        fputc(c,h);

    
    fclose(p);
    fclose(h);

    return 0;

}
#include<stdio.h> 

int Check(char* ch){
    
    while(*ch!='\0'){
        if(*ch=='a')
            return 0;
        ch++;
    }

    return 1;

}

int main(void){

    FILE* p=fopen("file1.txt","rt");
    FILE* h=fopen("file2.txt","wt");

    char ch[20];
    
    while(fgets(ch,20,p)!=NULL){
        if(Check(ch))
            fputs(ch,h);
    }
        

    fclose(p);
    fclose(h);

    return 0;

}
#include<stdio.h> 

int main(void){

    FILE* p=fopen("file1.txt","rt");

    fseek(p,0L,2);
        
    printf("%d",ftell(p));

    fclose(p);
    

    return 0;

}
#include<stdio.h> 
#include<string.h>

typedef struct Stu{
    char id[10];
    char name[30];
    int g1;
    int g2;
    int g3;
}Stu;

int main(void){

    FILE* p=fopen("file1.txt","wt");

    Stu arr[5];
    int i=0;
    char ch[30];

    for(i=0;i<5;i++){
        scanf("%s",ch);
        strcpy(arr[i].id,ch);
        scanf("%s",ch);
        strcpy(arr[i].name,ch);
        scanf("%d %d %d",&arr[i].g1,&arr[i].g2,&arr[i].g3);
    }

    int g[3]={0};
    for(i=0;i<5;i++){
        fprintf(p,"%s %s %d %d %d\n",arr[i].id,arr[i].name,arr[i].g1,arr[i].g2,arr[i].g3);
        g[0]+=arr[i].g1;
        g[1]+=arr[i].g2;
        g[2]+=arr[i].g3;
    }

    fprintf(p,"%d %d %d",g[0]/5,g[1]/5,g[2]/5);

    
    fclose(p);

    return 0;

}
posted @ 2024-12-03 22:07  hfdc  阅读(6)  评论(0编辑  收藏  举报