Skip to content

Commit

Permalink
i m back 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TGSpock123 committed Jan 1, 2024
1 parent b3e2254 commit 2a97ee2
Show file tree
Hide file tree
Showing 49 changed files with 964 additions and 1,288 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added .cache/jb/UpdateWork.dat
Binary file not shown.
1 change: 1 addition & 0 deletions .cache/jb/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(ssh://[email protected]/llvm/llvm-project.git f366c1b339fcef61a79a15dac779e79b1e636e7a based on LLVM 35b10acf201ab873fab4423a37ae6dbe52591f6d revision)
Binary file added 10_plus/.DS_Store
Binary file not shown.
25 changes: 4 additions & 21 deletions 10_plus/10.6.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <stdio.h>
#define MONTHS 12
#define YEARS 5
#include "10.6_32.h"
int main (void)
{
const float rain[YEARS][MONTHS] =
Expand All @@ -26,31 +25,15 @@ int main (void)
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;
}
avry (rain, &total, &subtot);
printf ("\nThe yearly average is %.1f inches. \n\n", total / YEARS);
printf ("MONTHLY AVERAGES: \n");
printf ("Jan Feb Mar Apr May Jun Jui Aug Sep Oct Nov Dec \n");
for (month = 0; month < MONTHS; month ++)
{
for (year = 0, subtot = 0; year < YEARS; year ++)
{
subtot += rain[year][month];
}
printf ("%-6.1f", subtot / YEARS);
}
avrm(rain, &subtot);
printf ("\n");

return 0;
}
}
Binary file modified 10_plus_2/.DS_Store
Binary file not shown.
29 changes: 19 additions & 10 deletions 10_plus_2/10_plus_2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
7A4DCA472B370C7A00B98E89 /* 10.26.c in Sources */ = {isa = PBXBuildFile; fileRef = 7A4DCA452B370C7A00B98E89 /* 10.26.c */; };
7A4DCA482B370C7A00B98E89 /* 10.27.c in Sources */ = {isa = PBXBuildFile; fileRef = 7A4DCA462B370C7A00B98E89 /* 10.27.c */; };
7AA697D52B381E840063E664 /* 10.last.c in Sources */ = {isa = PBXBuildFile; fileRef = 7AA697D42B381E840063E664 /* 10.last.c */; };
7AA697D72B381E9E0063E664 /* 10.last_2.c in Sources */ = {isa = PBXBuildFile; fileRef = 7AA697D62B381E9E0063E664 /* 10.last_2.c */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -25,9 +25,9 @@

/* Begin PBXFileReference section */
7A4DCA3A2B370C0A00B98E89 /* 10_plus_2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = 10_plus_2; sourceTree = BUILT_PRODUCTS_DIR; };
7A4DCA442B370C7A00B98E89 /* 10.26_27.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 10.26_27.h; sourceTree = "<group>"; };
7A4DCA452B370C7A00B98E89 /* 10.26.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = 10.26.c; sourceTree = "<group>"; };
7A4DCA462B370C7A00B98E89 /* 10.27.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = 10.27.c; sourceTree = "<group>"; };
7AA697D42B381E840063E664 /* 10.last.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = 10.last.c; sourceTree = "<group>"; };
7AA697D62B381E9E0063E664 /* 10.last_2.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = 10.last_2.c; sourceTree = "<group>"; };
7AA697D82B381EAD0063E664 /* 10.last.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 10.last.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -46,6 +46,7 @@
children = (
7A4DCA3C2B370C0A00B98E89 /* 10_plus_2 */,
7A4DCA3B2B370C0A00B98E89 /* Products */,
AE9F28F273E9A70F1C7D5CCA /* xcschemes */,
);
sourceTree = "<group>";
};
Expand All @@ -60,13 +61,21 @@
7A4DCA3C2B370C0A00B98E89 /* 10_plus_2 */ = {
isa = PBXGroup;
children = (
7A4DCA442B370C7A00B98E89 /* 10.26_27.h */,
7A4DCA452B370C7A00B98E89 /* 10.26.c */,
7A4DCA462B370C7A00B98E89 /* 10.27.c */,
7AA697D42B381E840063E664 /* 10.last.c */,
7AA697D62B381E9E0063E664 /* 10.last_2.c */,
7AA697D82B381EAD0063E664 /* 10.last.h */,
);
path = 10_plus_2;
sourceTree = "<group>";
};
AE9F28F273E9A70F1C7D5CCA /* xcschemes */ = {
isa = PBXGroup;
children = (
);
name = xcschemes;
path = 10_plus_2.xcodeproj/project.xcworkspace/xcuserdata/tgspock.xcuserdatad/xcschemes;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -124,8 +133,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7A4DCA482B370C7A00B98E89 /* 10.27.c in Sources */,
7A4DCA472B370C7A00B98E89 /* 10.26.c in Sources */,
7AA697D72B381E9E0063E664 /* 10.last_2.c in Sources */,
7AA697D52B381E840063E664 /* 10.last.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict />
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction>
<BuildActionEntries>
<BuildActionEntry
buildForRunning = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7A4DCA392B370C0A00B98E89"
BuildableName = "10_plus_2"
BlueprintName = "10_plus_2"
ReferencedContainer = "container:10_plus_2.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<LaunchAction
useCustomWorkingDirectory = "YES"
buildConfiguration = "Debug"
allowLocationSimulation = "YES"
customWorkingDirectory = "/Users/tgspock/Documents/GitHub/learn_c_primer.github.io/10_plus_2">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7A4DCA392B370C0A00B98E89"
BuildableName = "10_plus_2"
BlueprintName = "10_plus_2"
ReferencedContainer = "container:10_plus_2.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>10_plus_2.xcscheme_^#shared#^_</key>
<key>10_plus_2.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
Expand Down
Binary file added 10_plus_2/10_plus_2/.DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions 10_plus_2/10_plus_2/10.25.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdio.h>
#include "10.25_29.h"
int main (void)
{
int n, m;
double source_1[5] = {1.1, 2.2, 3.3, 4.4, 5.5};
double source_2[2][7] = {{2.1, 3.4, 1.5, 4.9, 9.3, 5.2, 6.8}, {6.8, 5.2, 9.3, 4.9, 1.5, 3.4, 2.1}};
double target_1_1 [5];
double target_1_2[5];
double target_1_3[5];
double target_2_1[2][7];
double target_2_2[3];

copy_arr (target_1_1, source_1, 5);
copy_ptr (target_1_2, source_1, 5);
copy_ptrs (target_1_3, source_1, source_1 + 5);
for (n = 0; n < 5; n ++)
{
printf ("source[%d] = %g, target[%d] = %g, target2[%d] = %g, target3[%d] = %g\n", n, source_1[n], n,
target_1_1[n], n, target_1_2[n], n, target_1_3[n]);
}
for (n = 0; n < 2; n ++)
{
copy_arr(target_2_1[n], source_2[n], 7);
}
for (n = 0; n < 2; n ++)
{
for (m = 0; m < 7; m ++)
{
printf ("target_2_1[%d][%d] = %g \n", n, m, target_2_1[n][m]);
}
}
copy_arr(target_2_2, &source_2[0][2], 3);
for (n = 0; n < 3; n ++)
{
printf ("target_2_2[%d] = %g \n", n, target_2_2[n]);
}

return 0;
}
14 changes: 14 additions & 0 deletions 10_plus_2/10_plus_2/10.25_29.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// 10.25_29.h
// 10_plus_2
//
// Created by T G Spock on 2023/12/23.
//

#ifndef _0_25_29_h
#define _0_25_29_h
void copy_arr (double ar[], const double m[], int n);
void copy_ptr (double * str, const double * q, int n);
void copy_ptrs (double ar[], const double * m, const double * p);

#endif /* _0_25_29_h */
11 changes: 8 additions & 3 deletions 10_plus_2/10_plus_2/10.26.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "10.26_27.h"
int main (void)
{
int qwer[10] = {4, 2, 6, 3, 1, 9, 5,0,8, 7};
double tyui[10] = {4.4, 2.2, 6.6, 3.3, 1.1, 9.9, 0.9, 8.8, 7.7};
int qwer[10] = {4, 2, 6, 3, 1, 9, 5, 0, 8, 7};
double tyui[10] = {4.4, 2.2, 6.6, 3.3, 1.1, 9.9, 0.9, 8.8, 7.7, 55};

printf ("Max of qwer is %d \n", max (qwer, 10));
bubble (qwer, 10);
Expand All @@ -13,6 +13,11 @@ int main (void)
}
printf ("The subscript of max of tyui is %d \n", maxm(tyui, 10));
printf ("Max of tyui - min of tyui is %f \n", minus(tyui, 10));

bubble_opp(tyui, 10);
for (int i = 0; i < 10; i ++)
{
printf ("tyui [%d] = %g \n", i, tyui[i]);
}

return 0;
}
5 changes: 3 additions & 2 deletions 10_plus_2/10_plus_2/10.26_27.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
void sort (int * a, int * b);
void bubble (int ar[], int n);
int max (const int ar [], int n);
double minus (double ar[], int n);
int maxm (const double ar[], int n);
double minus (const double ar[], int n);
int maxm (const double ar[], int n);
void bubble_opp (double ar[], int n);
37 changes: 29 additions & 8 deletions 10_plus_2/10_plus_2/10.27.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ void sort (int * a, int *b)
*a = *b;
*b = temp;
}
void sort_2 (double * a, double * b)
{
double temp;

temp = *a;
*a = *b;
*b = temp;
}
void bubble (int ar[], int n)
{
for (int i = 0; i < n - 1; i ++)
Expand All @@ -24,7 +32,7 @@ int max (const int ar [], int n)
{
int i = ar[0];

for (int q = 0; q < n - 1; q ++)
for (int q = 0; q < n; q ++)
{
if (i < ar[q])
{
Expand All @@ -33,29 +41,29 @@ int max (const int ar [], int n)
}
return i;
}
double minus (double ar[], int n)
double minus (const double ar[], int n)
{
double i = ar[0];
double i = ar[0], j = ar[0];

for (int q = 0; q < n - 1; q ++)
for (int q = 0; q < n; q ++)
{
if (i < ar[q])
{
i = ar[q];
}
if (ar[0] > ar[q])
if (j > ar[q])
{
ar[0] = ar[q];
j = ar[q];
}
}

return (i - ar[0]);
return (i - j);
}
int maxm (const double ar[], int n)
{
int i = 0, p = 0;

for (double q = ar[0]; i < n - 1; i ++)
for (double q = ar[0]; i < n; i ++)
{
if (q < ar[i])
{
Expand All @@ -66,3 +74,16 @@ int maxm (const double ar[], int n)

return p;
}
void bubble_opp (double ar[], int n)
{
for (int i = 0; i < n - 1; i ++)
{
for (int j = 0; j < (n - i - 1); j ++)
{
if (ar[j] < ar[j + 1])
{
sort_2 (&ar[j], &ar[j + 1]);
}
}
}
}
32 changes: 32 additions & 0 deletions 10_plus_2/10_plus_2/10.29.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// 10.29.c
// 10_plus_2
//
// Created by T G Spock on 2023/12/23.
//

#include <stdio.h>
#include "10.25_29.h"
void copy_arr (double ar[], const double m[], int n)
{
for (int i = 0; i < n; i ++)
{
ar[i] = m[i];
}
}
void copy_ptr (double * str, const double * q, int n)
{
for (int i = 0; i < n; i ++)
{
*str = *q;
str ++;
q ++;
}
}
void copy_ptrs (double ar[], const double * m, const double * p)
{
for (; m < p; m ++, ar ++)
{
*ar = *m;
}
}
28 changes: 28 additions & 0 deletions 10_plus_2/10_plus_2/10.30.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// 10.30.c
// 10_plus_2
//
// Created by T G Spock on 2023/12/24.
//

#include <stdio.h>
#include "10.30_31.h"
int main (void)
{
int q = 3, p = 5;
double qwer[3][5] = {
{1.1, 2.2, 3.3, 4.4, 5.5}, {6.6, 7.7, 8.8, 9.9, 10.01}, {11.12, 12.13, 13.14, 14.15, 15.16}
};
double tyui[q][p];
double opas[q][p];

ons (4, "qwer", 3, 5, qwer);
cpy (3, 5, tyui, qwer);
ons (4, "tyui", 3, 5, tyui);
pluz (3, 5, tyui, qwer, opas);
ons (4, "opas", 3, 5, opas);
tims (3, 5, qwer);
ons (8, "now qwer", 3, 5, qwer);

return 0;
}
Loading

0 comments on commit 2a97ee2

Please sign in to comment.