Skip to content

Commit

Permalink
emergency upload 4.16
Browse files Browse the repository at this point in the history
  • Loading branch information
TGSpock123 committed Apr 16, 2024
1 parent 416f263 commit caa5ae9
Show file tree
Hide file tree
Showing 127 changed files with 1,887 additions and 342 deletions.
3 changes: 3 additions & 0 deletions .idea/dictionaries/tgspo.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/material_theme_project_new.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .vs/cmake.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/learn_c_primer.github.io/v17/.wsuo
Binary file not shown.
Binary file modified .vs/learn_c_primer.github.io/v17/Browse.VC.db
Binary file not shown.
49 changes: 33 additions & 16 deletions .vs/learn_c_primer.github.io/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
"WorkspaceRootPath": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.12.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:13\\13.12.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\CppProperties.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:CppProperties.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.12.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:13\\13.12.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.11.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:13\\13.11.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
Expand Down Expand Up @@ -75,7 +79,8 @@
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAcAAAAPAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003109|",
"WhenOpened": "2024-03-18T11:42:28.879Z",
"IsPinned": true
"IsPinned": true,
"EditorCaption": ""
},
{
"$type": "Bookmark",
Expand All @@ -84,19 +89,31 @@
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "CppProperties.json",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\CppProperties.json",
"RelativeDocumentMoniker": "CppProperties.json",
"ToolTip": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\CppProperties.json",
"RelativeToolTip": "CppProperties.json",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAeAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
"WhenOpened": "2024-04-13T17:23:39.189Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "13.12.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.12.c",
"RelativeDocumentMoniker": "13\\13.12.c",
"ToolTip": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.12.c",
"RelativeToolTip": "13\\13.12.c",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAA4AAAAjAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|",
"WhenOpened": "2024-03-29T05:47:38.075Z",
"EditorCaption": ""
"WhenOpened": "2024-03-29T05:47:38.075Z"
},
{
"$type": "Document",
"DocumentIndex": 2,
"DocumentIndex": 3,
"Title": "13.11.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.11.c",
"RelativeDocumentMoniker": "13\\13.11.c",
Expand All @@ -108,7 +125,7 @@
},
{
"$type": "Document",
"DocumentIndex": 3,
"DocumentIndex": 4,
"Title": "13.10.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.10.c",
"RelativeDocumentMoniker": "13\\13.10.c",
Expand All @@ -120,7 +137,7 @@
},
{
"$type": "Document",
"DocumentIndex": 6,
"DocumentIndex": 7,
"Title": "13.9.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.9.c",
"RelativeDocumentMoniker": "13\\13.9.c",
Expand All @@ -132,7 +149,7 @@
},
{
"$type": "Document",
"DocumentIndex": 4,
"DocumentIndex": 5,
"Title": "doubleCal.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\doubleCal.c",
"RelativeDocumentMoniker": "13\\doubleCal.c",
Expand All @@ -144,7 +161,7 @@
},
{
"$type": "Document",
"DocumentIndex": 9,
"DocumentIndex": 10,
"Title": "13.1.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.1.c",
"RelativeDocumentMoniker": "13\\13.1.c",
Expand All @@ -156,7 +173,7 @@
},
{
"$type": "Document",
"DocumentIndex": 7,
"DocumentIndex": 8,
"Title": "13.5.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.5.c",
"RelativeDocumentMoniker": "13\\13.5.c",
Expand All @@ -168,7 +185,7 @@
},
{
"$type": "Document",
"DocumentIndex": 8,
"DocumentIndex": 9,
"Title": "13.8.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.8.c",
"RelativeDocumentMoniker": "13\\13.8.c",
Expand All @@ -180,7 +197,7 @@
},
{
"$type": "Document",
"DocumentIndex": 5,
"DocumentIndex": 6,
"Title": "s_gets.h",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\s_gets.h",
"RelativeDocumentMoniker": "13\\s_gets.h",
Expand All @@ -192,7 +209,7 @@
},
{
"$type": "Document",
"DocumentIndex": 11,
"DocumentIndex": 12,
"Title": "s_gets.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\s_gets.c",
"RelativeDocumentMoniker": "13\\s_gets.c",
Expand All @@ -204,7 +221,7 @@
},
{
"$type": "Document",
"DocumentIndex": 10,
"DocumentIndex": 11,
"Title": "13.7.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.7.c",
"RelativeDocumentMoniker": "13\\13.7.c",
Expand All @@ -216,7 +233,7 @@
},
{
"$type": "Document",
"DocumentIndex": 12,
"DocumentIndex": 13,
"Title": "13.6.c",
"DocumentMoniker": "C:\\Users\\tgspo\\Documents\\GitHub\\learn_c_primer.github.io\\13\\13.6.c",
"RelativeDocumentMoniker": "13\\13.6.c",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified .vs/learn_c_primer.github.io/v17/workspaceFileList.bin
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
77 changes: 77 additions & 0 deletions 14/14.1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//加强版;
#include "s_gets.h"
#define MAXTITL 30
#define MAXBK 100
//声明结构;
struct book
{
char title[MAXTITL], author[MAXTITL];
float value;
};

int main (void)
{
//声明结构变量;
struct book library[MAXBK], * lib;
int j = 0;
char ch;

lib = library;
printf ("Please enter the book title. \n");
printf ("While less than 30 books, enter an empty line anytime to quit. \n");

//逐个存入书籍信息并在循环中存入title, 如果用户按下回车则结束任务, 注意指针使用方法;
for (; (j < MAXBK) && (s_gets_1 (lib -> title, MAXTITL)) && (lib -> title[0]); j ++, lib ++)
{
//存入author;
printf ("Please enter the author. \n");
if (!(s_gets_1 (library[j].author, MAXTITL)) || (!library[j].author[0]))
{
break;
}

//存入value;
printf ("Now enter the value. \n");
//如果读到'\n'则结束任务, 如果不是则将刚刚读到的字符放回输入流;
if ((ch = getchar()) == '\n')
{
break;
}
ungetc (ch, stdin);
//如果读到非数字则要求输入数字并清空缓冲区;
while (!(scanf ("%f", &library[j].value)))
{
printf ("Please enter a number. \n");
fflush (stdin);
}
getchar();

printf ("Please enter next book title: \n");
}

//打印;
if (j == 0)
{
printf ("No input. \n");
return 1;
}

for (int p1 = 0; p1 < 80; p1 ++)
{
putchar ('-');
}
putchar ('\n');
for (int p = 0; p < j; p ++)
{
printf ("| %-29s| %-29s| $%-14.2f|\n", library[p].title, library[p].author, library[p].value);
for (int p1 = 0; p1 < 80; p1 ++)
{
putchar ('-');
}
putchar ('\n');
}

printf ("\nDone. \n");

return 0;
}
42 changes: 42 additions & 0 deletions 14/14.10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>

//如下声明的结构具备伸缩特性, 该结构不能直接拷贝, 须使用memcpy()进行拷贝;
struct flex
{
int count;
double average;
double scores[];
};

int main (void)
{
struct flex * pf = malloc (sizeof (struct flex) + 5 * sizeof (double));
struct flex * asdf = malloc (sizeof (struct flex) + 9 * sizeof (double));

printf ("please enter 5 numbers. \n");
for (int j = 0; j < 5; j ++)
{
scanf ("%lf", &pf -> scores[j]);
}
for (int p = 0; p < 5; p ++)
{
printf ("%lf ", pf -> scores[p]);
}
putchar ('\n');

printf ("please enter 9 numbers. \n");
for (int j = 0; j < 9; j ++)
{
scanf ("%lf", &asdf -> scores[j]);
}
for (int p = 0; p < 9; p ++)
{
printf ("%lf ", asdf -> scores[p]);
}
putchar ('\n');

free (pf);
free (asdf);
return 0;
}
57 changes: 57 additions & 0 deletions 14/14.11.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <stdio.h>
#include <stdlib.h>

struct flex
{
size_t count;
double average;
double scores [];
};

void showFlex (const struct flex * p);

int main (void)
{
struct flex * pf1, * pf2;
int n = 5, i, tot = 0;

pf1 = malloc (sizeof (struct flex) + n * sizeof (double));

pf1 -> count = n;
for (i = 0; i < n; i ++)
{
(pf1 -> scores[i]) = 20.0 - i;
tot += (pf1 -> scores[i]);
}
(pf1 -> average) = tot / n;
showFlex (pf1);

n = 9, tot = 0;
pf2 = malloc (sizeof (struct flex) + n * sizeof (double));
pf2 -> count = n;
for (i = 0; i < n; i ++)
{
(pf2 -> scores[i]) = 20.0 - i / (float)2; //此处 "/ 2" 和 "/ 2.0" 会得到不同结果;
tot += (pf2 -> scores[i]);
}
(pf2 -> average) = tot / n;
showFlex (pf2);

free (pf1);
free (pf2);
return 0;
}

void showFlex (const struct flex * p)
{
int i;

printf ("Scores: ");

for (i = 0; i < (p -> count); i ++)
{
printf ("%g ", (p -> scores[i]));
}

printf ("\nAverage: %g\n", (p -> average));
}
Loading

0 comments on commit caa5ae9

Please sign in to comment.