# HNUST-C language course design completion quality test record·

Posted by digitalbart2k on Fri, 25 Feb 2022 16:58:06 +0100

Write before:

It's time for the c language class, which has been watered for more than a week, to come to an end

--Here's Friday's "C language course design completion quality test", a salute to the sky

Problem solving ideas:

Water question water to the extreme. (the only "trap" is probably that the penultimate line is empty)

```#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("1. Input record\n");
printf("2. Show all records\n");
printf("3. Sort all records\n");
printf("4. Find and display records by name\n");
printf("5. insert record\n6. Delete record\n7. Save all records to file\n8. Read all records from file\n9. sign out\n***********************************\n\n Please select an action(1-9):");

}
```

Problem solving ideas:

Although our curriculum is not the game production of strong schools, our examination is a game -- [find different * University of science and technology version]

Among the four errors, there are two output errors, one loop condition error and one pointer error.

The problem is not difficult, but disgusting (mouth area)

Screenshots of wa and ac pasted:

```#include<stdio. h> / / printf(), scanf(), and other functions
#include<string. h> / / strlen(), strcpy(), and other functions
#include<stdlib. h> / / atoi() function

//Define constant
#define N 3

//Define structure
typedef struct student
{
char no[11];
char name[15];
float score[N];
float sum;
float average;
int order;
}STUDENT;

/*Simple test data entry function*/
int input(STUDENT *stud,int n)
{
printf("\n You have successfully executed input()Function!\n");
return(n+1);
}

/*Simple test display module*/
void print(STUDENT *stud,int n)
{
printf("\n You have successfully executed print()Function!\n");
}

/*Simple test sorting module*/
void sort(STUDENT *stud,int n)
{
printf("\n You have successfully executed sort()Function!\n");
}

/*Simple test search record module*/
void search(STUDENT stud[],int n)
{
printf("\n You have successfully executed search()Function!\n");
}

/*Simple test inserts a record at the specified location*/
int insert(STUDENT *stud,int n)
{
printf("\n You have successfully executed insert()Function!\n");
return n+1;
}

/*Simple test delete record module*/
int delete1(STUDENT *stud,int n)
{
printf("\n You have successfully executed delete1()Function!\n");
return n-1;
}

/*Simple test save data to file module*/
void save(STUDENT *stud,int n)
{
printf("\n You have successfully executed save()Function!\n");
}

/*Simple test import information module*/
{
printf("\n You have successfully executed load()Function!\n");
return 1;
}
/*Menu function, the return value is an integer*/
{
char s[3];
int c=0;
printf("1. Input record\n");
printf("2. Show all records\n");
printf("3. Sort all records\n");
printf("4. Find and display records by name\n");
printf("5. insert record\n");
printf("6. Delete record\n");
printf("7. Save all records to file\n");
printf("8. Read all records from file\n");
printf("9. sign out\n");
printf("***********************************\n");

do
{
scanf("%s",s);
c=atoi(s);
}while(c<1||c>9); /*The selected item is not re entered between 1 and 9*/
return(c); /*Return the selection item, and the main program calls the corresponding function according to the number*/
}

/******Main function start*******/

int main(void)
{
int n=0;
STUDENT student[20];		/*Define structure array*/

switch(menu_select())               /*Call the main menu function and return the integer value as the condition of the switch statement*/
{
case 1: input(student,n);break;			/*New record*/
case 2: print(student,n);break;			/*Show all records*/
case 3: sort(student,n);break;				/*sort*/
case 4: search(student,n);break;			/*find record*/
case 5: insert(student,n);break;			/*insert record*/
case 6: delete1(student,n);break;		        /*Delete record*/
case 7: save(student,n);break;				/*Save file*/
case 9: exit(0);					/*Program end*/
}

return 0;
}
```

Problem solving ideas:

The difficulty of this problem lies not in the completion, but in the format of output. This time, we are not looking for differences, but in the mentality of non-stop wa

(smiling)

The screenshots of wa and ac are also posted, which makes me doubt my life (fortunately, the exam is not a competition)

```#include<stdio. h> / / printf(), scanf(), and other functions
typedef struct student
{
char xueHao[11];
char xingMing[15];
double chengJi[3];
double zongFen;
double pingJunFen;
int mingCi;
}STUDENT;
void print(int n,STUDENT stud[]   )   /*Please define the parameters of the print function completely*/
{
int i=0;                /* Number of statistical records*/
if(n==0)
{
printf("\n Unfortunately, there are no records in the empty table to display!\n");
}
else
{
printf("********************************** STUDENT ****************************************\n");
printf("   Location number　  Student number          full name      Score 1　Score 2　Score 3    Average ranking of total score\n");
printf("-----------------------------------------------------------------------------------\n");
while(i<n)
{
printf("    %-4d %-11s%-12s%7.2f%7.2f%7.2f %9.2f  %6.2f  %3d \n", i, stud[i].xueHao,stud[i].xingMing,stud[i].chengJi[0],stud[i].chengJi[1],
stud[i].chengJi[2],stud[i].zongFen,stud[i].pingJunFen,stud[i].mingCi);
i++;
}
printf("***********************************************************************************\n");
}
}

/******Main function start*******/
int main(void)
{
STUDENT student[20]={{"2105030155","zhaoxiaozhao",{100,100,100},300,100,0},
{"2105030166","qianxiaoqian",{99,99,99},297,99,0},
{"2105030177","sunxiaosun",{98,98,98},294,98,0},
{"2105030188","lixiaoli",{98,98,98},294,98,0}};/*Define the structure array and initialize the array elements at positions 0, 1, 2 and 3*/
int n;
scanf("%d",&n);
print(n,student  );       /*Please set the argument of the print() function*/
return 0;
}
```

Problem solving idea: just rush, solve in a cycle, that is, pay attention to i --, not the habitual i + + (smile)

``` for(i=n+1; i>position; i--)
{
stud[i]=stud[i-1];
}
```

Problem solving idea: I haven't used the pointer for a long time. I stuck in the grammar for a short time. It's not difficult. Rush!

```for( i=0; i<n; i++)scanf("%d",&a[i]);
p=&a[0];
for( i=0; i<n; i++)
{
if(a[i]>*p)p=&a[i];
}
```

Problem solving ideas: while cycle, it's not as difficult as the linked list problem behind the class, water. Note the condition of cnt increase

```while(p){

printf("%s %d\n",p->name,p->score);
if(p->score>=60)cnt++;
p=p->next;

}
printf("%d",cnt);```

Problem solving idea: output while reading

``` #include<stdio.h>
#include<string.h>
int main(){
char a[100][100];
int i;
for( i=0; i<56; i++)scanf("%s",a[i]);
int j;
for(i=0;i<56;i++){
for(j=0;j<strlen(a[i]);j++){
if(a[i][j]=='_')printf("00");
if(a[i][j]=='X')printf("11");

}printf("\n");

}
}
```

Problem solving ideas: there are a few words in the problem, which can be solved by circulation (water)

```#include<stdio.h>
#include<string.h>
int main()
{
int a[200][200];
int n;
scanf("%d",&n);
for(int i=0; i<n; i++)for(int j=0; j<n; j++)scanf("%1d",&a[i][j]);
for(int i=n-1; i>=0; i--)
{
for(int j=0; j<n; j++)
{
if(a[i][j]==0)printf("FF FF FF ");
else printf("00 00 FF ");
}

}

}
```

Write at the end:

It's not boasting about the difficulty of the topic, but it doesn't match the class design problem (water);

Personal status: a little weak chicken, write down this article and record the first class setting.

See this without leaving a praise and collection (hey, hey, hey), a wave of comments is also a good drop, slip away.

Topics: C