forked from zhayujie/C-Primer-Plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
993 changed files
with
31,801 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <stdio.h> | ||
#define MONTHS 12 //一年的月份数 | ||
#define YEARS 5 //一年的年数 | ||
int main(void) | ||
{ | ||
//用2010~2014年的降水量数据初始化数组 | ||
const float rain[YEARS][MONTHS] = | ||
{ | ||
{4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6}, | ||
{8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3}, | ||
{9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4}, | ||
{7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.7,4.3,6.2}, | ||
{7.6,5.6,3.8,2.8,3.8,0.2,0.0,0.0,0.0,1.3,2.6,5.2} | ||
}; | ||
int year, month; | ||
float subtot, total; | ||
|
||
printf(" YEAR RAINFALL (inches)\n"); | ||
for (year = 0, total = 0; year < YEARS; year++) | ||
{ //每一年,个月降水量总和 | ||
for (month = 0, subtot = 0; month < MONTHS; month++) | ||
subtot += *(*(rain + year) + month); | ||
printf("%5d %15.1f\n", 2010 + year, subtot); | ||
total += subtot; //5年的总降水量 | ||
} | ||
printf("\n The yearly average is %.1f inches.\n\n", total / YEARS); | ||
printf(" MONTHLY AVERAGES:\n\n"); | ||
printf(" Jan Feb Mar Apr May Jun Jul Aug Sep Oct "); | ||
printf(" Nov Dec\n"); | ||
|
||
for (month = 0; month < MONTHS; month++) | ||
{ | ||
for (year = 0, subtot = 0; year < YEARS; year++) | ||
subtot += *(*(rain + year) +month); | ||
printf("%4.1f ", subtot / YEARS); | ||
} | ||
printf("\n"); | ||
|
||
return 0; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Microsoft Developer Studio Workspace File, Format Version 6.00 | ||
# ����: ���ܱ༭��ɾ���ù������ļ��� | ||
|
||
############################################################################### | ||
|
||
Project: "1"=".\1.dsp" - Package Owner=<4> | ||
|
||
Package=<5> | ||
{{{ | ||
}}} | ||
|
||
Package=<4> | ||
{{{ | ||
}}} | ||
|
||
############################################################################### | ||
|
||
Global: | ||
|
||
Package=<5> | ||
{{{ | ||
}}} | ||
|
||
Package=<3> | ||
{{{ | ||
}}} | ||
|
||
############################################################################### | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<html> | ||
<body> | ||
<pre> | ||
<h1>Build Log</h1> | ||
<h3> | ||
--------------------Configuration: 1 - Win32 Debug-------------------- | ||
</h3> | ||
<h3>Command Lines</h3> | ||
Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP5C09.tmp" with contents | ||
[ | ||
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/1.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c | ||
"D:\zxjbc\��ʮ��\1.c" | ||
] | ||
Creating command line "cl.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP5C09.tmp" | ||
Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP5C1A.tmp" with contents | ||
[ | ||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/1.pdb" /debug /machine:I386 /out:"Debug/1.exe" /pdbtype:sept | ||
".\Debug\1.obj" | ||
] | ||
Creating command line "link.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP5C1A.tmp" | ||
<h3>Output Window</h3> | ||
Compiling... | ||
1.c | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(9) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(10) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(11) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(12) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
D:\zxjbc\��ʮ��\1.c(13) : warning C4305: 'initializing' : truncation from 'const double ' to 'const float ' | ||
Linking... | ||
|
||
|
||
|
||
<h3>Results</h3> | ||
1.exe - 0 error(s), 0 warning(s) | ||
</pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#define SIZE 4 | ||
void print_ar(double ar[], int n); //打印数组元素的函数 | ||
//将两个数组相加放入第三个数组的函数 | ||
void add_ar(double ar1[], double ar2[], double ar3[], int n); | ||
int main(void) | ||
{ | ||
double ar1[SIZE] = {2, 4, 5, 8}; | ||
double ar2[SIZE] = {1, 0, 4, 6}; | ||
double ar3[SIZE]; | ||
|
||
printf("The first array: "); | ||
print_ar(ar1, SIZE); | ||
printf("The second array: "); | ||
print_ar(ar2, SIZE); | ||
add_ar(ar1, ar2, ar3, SIZE); | ||
printf("The third array: "); | ||
print_ar(ar3, SIZE); | ||
|
||
return 0; | ||
} | ||
|
||
void print_ar(double ar[], int n) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < n; i++) | ||
printf("%g ", ar[i]); | ||
printf("\n"); | ||
} | ||
|
||
void add_ar(double ar1[], double ar2[], double ar3[], int n) | ||
{ | ||
int i; | ||
|
||
for (i = 0; i < n; i++) | ||
ar3[i] = ar1[i] + ar2[i]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.