2023-2024-120231329《计算机基础与程序设计》第15周学习总结

发布时间 2024-01-06 21:45:20作者: 20231329向鲸凝

作业信息

这个作业属于哪个课程 https://edu.cnblogs.com/campus/besti/2023-2024-1-CFAP
这个作业要求在哪里 https://www.cnblogs.com/rocedu/p/9577842.html#WEEK15
这个作业的目标 课程总结
作业正文 ... 本博客链接

作业

(按顺序)每周作业链接汇总

第1周作业:快速浏览一遍教材计算机科学概论,课本每章提出至少一个自己不懂的或最想解决的问题并在期末回答这些问题
https://www.cnblogs.com/xjn123/p/17731511.html
|
第2周作业
计算机科学概论第1章并完成云班课测试
《C语言程序设计》第1章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17747140.html
|
第3周作业
计算机科学概论第2章,第3章 并完成云班课测试
《C语言程序设计》第2章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17759537.html
|

第4周作业
计算机科学概论第4章,第5章 并完成云班课测试
《C语言程序设计》第3章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17775881.html
|

第5周作业
计算机科学概论第6章 并完成云班课测试 《C语言程序设计》第4章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17793351.html
|

第6周作业
计算机科学概论第7章 并完成云班课测试 《C语言程序设计》第5章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17806093.html
|

第7周作业
计算机科学概论第8章 并完成云班课测试《C语言程序设计》第6章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17817851.html
|

第8周作业
计算机科学概论第9章 并完成云班课测试《C语言程序设计》第7章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17834374.html
|

第9周作业
计算机科学概论第10,11章 并完成云班课测试《C语言程序设计》第8章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17851560.html
|

第10周作业
计算机科学概论第12,13,14章 云班课测试《C语言程序设计》第9章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17864652.html
|

第11周作业
计算机科学概论第15,16章并完成云班课测试《C语言程序设计》第10章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17877445.html
|

第12周作业
《C语言程序设计》第12章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17901869.html
|

第13周作业
《C语言程序设计》第12章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17917252.html
|

第14周作业
《C语言程序设计》第13章并完成云班课测试
https://www.cnblogs.com/xjn123/p/17931335.html
|

实验报告链接汇总

实验一 实验名称:学习使用别出心裁的Linux命令学习法https://www.cnblogs.com/rocedu/p/4902411.html
2 通过cheat和man 学习实践https://www.cnblogs.com/rocedu/p/14891816.html中的列表中不少于10个命令。
实验二 基本控制结构编程练习

include <stdio.h>

include <stdlib.h>

include <time.h>

int main() {
int num1, num2, answer, user, score = 0;
char operator;
srand(time(NULL));

for (int i = 1; i <= 10; i++) {
    int num1 = rand() % 10 + 1;
    int num2 = rand() % 10 + 1;
    int op = rand() % 4;

    switch (op) {
        case 0:
            operator = '+';
            answer = num1 + num2;
            break;
        case 1:
            operator = '-';
            answer = num1 - num2;
            break;
        case 2:
            operator = '*';
            answer = num1 * num2;
            break;
        case 3:
            operator = '/';
            answer = num1 / num2;
            break;
    }

    printf("%d: %d %c %d = ", i, num1, operator, num2);
    scanf("%d", &user);

    if (user == answer) {
            int massage = rand() % 4;
            switch(massage){
                case 0:
                printf("Very good!\n");
                break;
            case 1:
                printf("Excellent!\n");
                break;
            case 2:
                printf("Nice work!\n");
                break;
            case 3:
                printf("Keep up the good work!\n");
                break;
            }
        score += 10;
     } else {
        int Message = rand() % 4;
        switch (Message) {
            case 0:
                printf("No. Please try again.\n");
                break;
            case 1:
                printf("Wrong. Try once more.\n");
                break;
            case 2:
                printf("Don't give up!\n");
                break;
            case 3:
                printf("Not correct. Keep trying.\n");
                break;
        }
    }
}


float accuracy = (float)score / 100;
printf("total score: %d\n", score);
printf("accuracy:%.2f%%\n",accuracy*100):

    if (accuracy>75){

    printf("good, you pass\n");
} else {
    printf("sorry, you lose\n");
}

return 0;

}

实验三 考试
实验四 基本控制结构编程练习
include <stdio.h>
define N 40

float average(float score[], int studentnum);
void mingcibiao(float score[], int studentid[], int studentnum);
void chengjibiao(float score[], int studentid[], int studentnum);

int main()
{
int studentid[N];
float score[N];
int studentnum;
float sum = 0;
int put;

printf("学生人数是多少:\n");
scanf("%d", &studentnum);
            for (int i = 0; i < studentnum; i++)
        {
            printf("学号:\n");
            scanf("%d", &studentid[i]);
            printf("成绩:\n");
            scanf("%f", &score[i]);

        }

if (studentnum > N)
{
    return -1;
}
do
{
    printf("(1)Append record\n");
    printf("(2)Calculate total and average score of course\n");
    printf("(3)Sort in descending order by score\n");
    printf("(4)Sort in ascending order by number\n");
    printf("(5)Search by number\n");
    printf("(6)Statistic analysis\n");
    printf("(7)List record\n");
    printf("(8)Exit\n");
    scanf("%d",&put);
    switch(put)
    {

    case 1:
    {
        for (int i = 0; i < studentnum; i++)
        {
            printf("学号:\n");
            scanf("%d", &studentid[i]);
            printf("成绩:\n");
            scanf("%f", &score[i]);

        }
        break;
    }
    case 2:
    {
            float sum=0;
            int i;
            for (i=0;i<studentnum;i++){
                    sum+=score[i];
            }
            float aver=sum/studentnum;
        printf("平均分:%.2f\n", aver);
        printf("总分:%.2f\n", sum);

break ;

    }

    case 3:
    {

printf("成绩表(按学号排序):\n");

            for (int i = 0; i < studentnum ; i++)
            {
                int max = i;

                for (int j = i + 1; j < studentnum; j++)
                {
                    if (score[j] > score[max])
                    {
                        max = j;
                    }
                }

                float tempscore = score[max];
                score[max] = score[i];
                score[i] = tempscore;

                int tempid = studentid[max];
                studentid[max] = studentid[i];
                studentid[i] = tempid;




            printf("学号:%d,成绩:%.2f\n", studentid[i], score[i]);
        }




        break;
    }

case 4: {
printf("成绩表(按分数排序):\n");

for (int i = 0; i < studentnum; i++) {
    int max = i;

    for (int j = i + 1; j < studentnum; j++) {
        if (score[j] > score[max]) {
            max = j;
        }
    }
    float tempscore = score[max];
    score[max] = score[i];
    score[i] = tempscore;

    int tempid = studentid[max];
    studentid[max] = studentid[i];
    studentid[i] = tempid;
}
for (int i = 0; i < studentnum; i++) {
    printf("第 %d 名: 学号 %d, 成绩 %.2f\n", i + 1, studentid[i], score[i]);
}

break;

}

    case 5:{
            for (int i = 0; i < studentnum; i++) {
    int max = i;

    for (int j = i + 1; j < studentnum; j++) {
        if (score[j] > score[max]) {
            max = j;
        }
    }
    float tempscore = score[max];
    score[max] = score[i];
    score[i] = tempscore;

    int tempid = studentid[max];
    studentid[max] = studentid[i];
    studentid[i] = tempid;}


  printf("输入你想查找的学生学号查找成绩和排名\n");
        scanf("%d",&studentid);
        int i;
        i=studentid;
        printf(" 排名:%d成绩%f ",i+1 ,score[i]);


        break;
        }


    case 6:
    {

        int perfect=0,good=0,medium=0,pass=0,fail=0;
        for (int i = 0; i < studentnum; i++)
        {
            if (score[i] >= 90 && score[i] <= 100)
            {
                perfect++;
            }
            else if (score[i] >= 80 && score[i] < 90)
            {
                good++;
            }
            else if (score[i] >= 70 && score[i] < 80)
            {
                medium++;
            }
            else if (score[i] >= 60 && score[i] < 70)
            {
                pass++;
            }
            else
            {
                fail++;
            }
        }
        float perfect1,good1,medium1,pass1,fail1;
        perfect1 = ((float)perfect / studentnum) * 100.0;
        good1 = ((float)good / studentnum) * 100.0;
        medium1 = ((float)medium / studentnum) * 100.0;
        pass1 = ((float)pass / studentnum) * 100.0;
        fail1 = ((float)fail / studentnum) * 100.0;

        printf("优秀(90-100):%d 百分比:%.2f\n",perfect,perfect1);
        printf("良好(80-90):%d 百分比:%.2f\n",good,good1);
        printf("中等(70-80):%d 百分比:%.2f\n",medium,medium1);
        printf("及格(60-70):%d 百分比:%.2f\n",pass,pass1);
        printf("不及格(0-60):%d 百分比:%.2f\n",fail,fail1);
        break;
    }
    case 7:
        printf("展示所有:\n");
            float sum=0;
            int i;
            for (i=0;i<studentnum;i++){
                    sum+=score[i];
            }
            float aver=sum/studentnum;
        for(i=0;i<studentnum;i++){
        printf("学号:%d\n",studentid[i]);
        printf("成绩:%f\n", score[i]);}
        printf("平均分:%.2f\n", aver);
        printf("总分:%.2f\n", sum);

break ;

    case 8:
    {
        break ;
    }

    }
}
while(put!=8);
return 0;

}
实验五 考试
实验六 文件与结构编程练习
3.源程序与运行结果
4.#include <stdio.h>
5.#include <stdlib.h>
6.#include <string.h>
7.
8.struct student
9.{
10. long studentid;
11. char name[40];
12. int math;
13. int English;
14. int PE;
15. int total;
16. float average;
17.} stu[40];
18.int num=0;
19.void appendRecord(struct student stu[], int n);
20.void totalaverage(struct student stu[], int n);
21.void rise(struct student stu[], int n);
22.void mcrise(struct student stu[], int n);
23.
24.
25.int main()
26.{
27. int num;
28. printf("input the number of students: \n");
29. scanf("%d", &num);
30.
31. for (int i = 0; i < num; i++)
32. {
33. printf("input id:\n ");
34. scanf("%ld", &stu[i].studentid);
35. printf("input name:\n ");
36. scanf("%s", &stu[i].name);
37. printf("input math score:\n ");
38. scanf("%d", &stu[i].math);
39. printf("input English score:\n ");
40. scanf("%d", &stu[i].English);
41. printf("input PE score:\n ");
42. scanf("%d", &stu[i].PE);
43. }
44.
45. int choice;
46. do
47. {
48. printf("\n1. Append record\n");
49. printf("2. Calculate total and average score of every student\n");
50. printf("3. Sort in ascending order by total score of every student\n");
51. printf("4. Sort in dictionary order by name\n");
52. printf("5. Search by name\n");
53. printf("6. Write to a file\n");
54. printf("7. Read from a file\n");
55. printf("8. Exit\n");
56. printf("Please enter your choice: \n");
57. scanf("%d", &choice);
58.
59. switch (choice)
60. {
61. case 1:
62. {
63. appendRecord(stu, num);
64. num++;
65. break;
66. }
67. case 2:
68. {
69. totalaverage(stu,num);
70.
71. break;
72. }
73. case 3:
74. {
75. rise(stu,num);
76. break;
77. }
78. case 4:
79. {
80. mcrise(stu,num);
81.
82. break;
83. }
84. case 5:
85. {
86. search(stu,num);
87. }
88. break;
89. case 6:
90. writefile(stu,num);
91. break;
92. case 7:
93. readfile(stu,num);
94. break;
95. case 8:
96. printf("Goodbye!\n");
97. break;
98.
99. }
100. }
101. while (choice != 8);
102.
103.
104.}
105.void appendRecord(struct student stu[],int num)
106.{
107.
108. printf("input id: \n");
109. scanf("%ld", &stu[num].studentid);
110. printf("input name: \n");
111. scanf("%s", stu[num].name);
112. printf("input math score:\n ");
113. scanf("%d", &stu[num].math);
114. printf("input English score:\n ");
115. scanf("%d", &stu[num].English);
116. printf("input PE score: \n");
117. scanf("%d", &stu[num].PE);
118.}
119.void totalaverage(struct student stu[], int n)
120.{
121. int i;
122.
123. for(i=0; i<n; i++)
124. {
125. stu[i].total=stu[i].math+stu[i].English+stu[i].PE;
126. stu[i].average= (float)stu[i].total / 3.0;
127. printf("Student %d - Total: %d\n", i + 1,stu[i].total);
128. printf("Student %d - Average: %.2f\n", i + 1, stu[i].average);
129. }
130.}
131.void rise(struct student stu[], int n)
132.{
133. int i, j;
134.
135. for (i = 0; i < n; i++)
136. {
137. for (j = i + 1; j < n; j++)
138. {
139. int total1 = stu[i].math + stu[i].English + stu[i].PE;
140. int total2 = stu[j].math + stu[j].English + stu[j].PE;
141.
142. if (total1 < total2)
143. {
144. struct student temp = stu[j];
145. stu[j] = stu[i];
146. stu[i] = temp;
147. }
148. }
149. int total = stu[i].math + stu[i].English + stu[i].PE;
150. printf(" %d : studentid %ld, name %s, total %d\n", i + 1, stu[i].studentid, stu[i].name, total);
151. }
152.
153.}
154.void mcrise(struct student stu[], int n)
155.{
156. int i, j;
157. struct student temp;
158.
159. for(i = 0; i < n - 1; i++)
160. {
161. for(j = i + 1; j < n; j++)
162. {
163. if (strcmp(stu[i].name, stu[j].name) > 0)
164. {
165. temp = stu[i];
166. stu[i] = stu[j];
167. stu[j] = temp;
168. }
169. }
170. }
171.
172.
173. for(i = 0; i < n; i++)
174. {
175. int total = stu[i].math + stu[i].English + stu[i].PE;
176. printf("%s,%d\n", stu[i].name,total);
177. }
178.}
179.
180.void search(struct student stu[], int n)
181.{
182. char input[50];
183. printf("input name\n");
184. scanf("%s",input);
185. int found =0;
186. for(int i=0; i<n; i++)
187. {
188. if(strcmp(stu[i].name,input)==0)
189. {
190. printf("%ld %s %d %d %d ", stu[i].studentid, stu[i].name,
191. stu[i].math, stu[i].English, stu[i].PE);
192. found = 1;
193. break;
194. }
195.
196. }
197.}
198.void writefile(struct student stu[], int n)
199.{
200. FILE *fp;
201. if ((fp = fopen("student.txt", "w")) == NULL)
202. {
203. printf("Failure to open student.txt!\n");
204. exit(0);
205. }
206. for (int i = 0; i < n; i++)
207. {
208. fprintf(fp, "Student ID: %d\n", stu[i].studentid);
209. fprintf(fp, "Name: %s\n", stu[i].name);
210. fprintf(fp, "Math Scores: %d\n", stu[i].math);
211. fprintf(fp, "English Scores: %d\n", stu[i].English);
212. fprintf(fp, "PE Scores: %d\n", stu[i].PE);
213.
214. fprintf(fp, "Total Score: %d\n",stu[i].total);
215.
216.
217. fprintf(fp, "Average Score: %f\n",stu[i].average);
218. }
219. fclose(fp);
220.}
221.
222.void readfile(struct student stu[], int n)
223.{
224. FILE *fp;
225. int i;
226.
227. if ((fp = fopen("student.txt", "r")) == NULL)
228. {
229. printf("Failure to open student.txt!\n");
230. exit(0);
231. }
232.
233. for (i = 0; i < n; i++)
234. {
235.
236. fscanf(fp,"studentid%d\n",&stu[i].studentid);
237. fscanf(fp, "Name: %s\n", stu[i].name);
238. fscanf(fp, "Math Scores: %f\n", &stu[i].math);
239. fscanf(fp, "English Scores: %f\n", &stu[i].English);
240. fscanf(fp, "PE Scores: %f\n", &stu[i].PE);
241. fscanf(fp, "Total Score: %d\n", &stu[i].total);
242. fscanf(fp, "Average Score: %f\n\n", &stu[i].average);
243. }
244. for (i = 0; i < n; i++)
245. {
246. printf("studentid: %d\n", stu[i].studentid);
247. printf("name: %s\n", stu[i].name);
248. printf("math: %d\n", stu[i].math);
249. printf("English: %d\n", stu[i].English);
250. printf("PE: %d\n", stu[i].PE);
251. printf("total: %d\n", stu[i].total);
252. printf("average: %f\n", stu[i].average);
253. }
254.
255. fclose(fp);
256.
257.}
258.
259.
260.
261.
262.
实验七 缓冲区溢出
实验八 Web部署

整体评价一下第1周作业中自己提出的问题是不是抓住了学习重点

回答一下第1周作业中自己提出的问题

课程收获与不足
收获:学习了一些比较基础的文件命令操作,会写一些基本的C语言
不足:学习运用的不够熟练,不太会用

自己的收获(投入,效率,效果等)
自己需要改进的地方

如果重新学习这门课,怎么做才可以学的更好
提前做到预习,不懂的地方要及时弄懂,不要一拖再拖,课下要加紧练习,不要只听补练,思考问题时要从多个方面考虑,不要只有单一的思维固化。