Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some improvements #40

Open
wants to merge 185 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
324a3d1
Update 3.c
ioprojecton Dec 27, 2019
0bf8a7d
Update 3.c
ioprojecton Dec 27, 2019
7db81db
Update 7.c
ioprojecton Dec 28, 2019
33b8209
Update 7.c
ioprojecton Dec 28, 2019
b56f7b7
Update 8.c
ioprojecton Dec 28, 2019
2d7efe4
Update 9.c
ioprojecton Dec 29, 2019
e598fee
Update 11.c
ioprojecton Dec 29, 2019
aa83f40
Update 12.c
ioprojecton Dec 29, 2019
44cdd89
Update 13.c
ioprojecton Dec 29, 2019
b45b1dc
Update 14.c
ioprojecton Dec 30, 2019
c7f5ea6
Update 15.c
ioprojecton Dec 30, 2019
feffed4
Update 16.c
ioprojecton Dec 31, 2019
18c323b
Merge pull request #1 from ioprojecton/ioprojecton-patch-1
ioprojecton Dec 31, 2019
559855a
Update README.md
ioprojecton Jan 4, 2020
33ce24d
Update README.md
ioprojecton Jan 4, 2020
001393b
Update README.md
ioprojecton Jan 4, 2020
0f4dea3
Update README.md
ioprojecton Jan 4, 2020
086fce9
Update README.md
ioprojecton Jan 5, 2020
daed92f
Update README.md
ioprojecton Jan 5, 2020
a38b5b2
Update README.md
ioprojecton Jan 5, 2020
c1abd4c
Update README.md
ioprojecton Jan 5, 2020
5b27b68
Update 1.c
ioprojecton Jan 9, 2020
3c6bd26
Update 3.c
ioprojecton Jan 9, 2020
40bf6b1
Update 4.c
ioprojecton Jan 10, 2020
adb6836
Update 6.c
ioprojecton Jan 10, 2020
4cdcf7a
Update 1.c
ioprojecton Jan 15, 2020
6b63fda
Update 2.c
ioprojecton Jan 15, 2020
b742cf2
Update 6.c
ioprojecton Jan 15, 2020
e91b01e
Update 1.c
ioprojecton Jan 26, 2020
82d39b6
Update 1.c
ioprojecton Jan 26, 2020
655d5ca
Update 1.c
ioprojecton Jan 28, 2020
c5bf6f3
Working code
ioprojecton Jan 29, 2020
7055d88
Update 6.c
ioprojecton Jan 29, 2020
d7f4172
same but in 1 char * array
ioprojecton Jan 30, 2020
5231194
Update 8.c
ioprojecton Jan 30, 2020
dba1787
Update 9.c
ioprojecton Jan 31, 2020
895c439
Update 11.c
ioprojecton Jan 31, 2020
64ce80b
Update 12.c
ioprojecton Feb 1, 2020
b041280
Update 13.c
ioprojecton Feb 1, 2020
1f6345f
Update 14.c
ioprojecton Feb 1, 2020
c237344
Update 15.c
ioprojecton Feb 1, 2020
f2fcfb9
Update 16.c
ioprojecton Feb 1, 2020
b04fa45
Update 18.c
ioprojecton Feb 1, 2020
4a37106
shorter
ioprojecton Feb 6, 2020
41febac
bugfix
ioprojecton Feb 8, 2020
9ea74c2
bugfix
ioprojecton Feb 9, 2020
e4018db
bugfix
ioprojecton Feb 9, 2020
7f7e0d7
working version without compiler warnings
ioprojecton Feb 16, 2020
ca86c81
Update README.md
ioprojecton Feb 16, 2020
4a7db06
Solution of (c) is wrong
ioprojecton Feb 24, 2020
331c263
No need to & with 0xff
ioprojecton Feb 25, 2020
6368d5d
Update README.md
ioprojecton Feb 25, 2020
34bba6f
Update README.md
ioprojecton Mar 22, 2020
e318ee0
Update README.md
ioprojecton Mar 22, 2020
fd31e29
Update README.md
ioprojecton Mar 22, 2020
09d71ca
Update 2.c
ioprojecton Mar 22, 2020
d98c300
Update fcat.c
ioprojecton Mar 22, 2020
398dbe9
Update fcat.c
ioprojecton Mar 22, 2020
2831a4a
Update fchar.c
ioprojecton Mar 23, 2020
1ea9431
Update fword.c
ioprojecton Mar 23, 2020
d5a0bd0
Update xor.c
ioprojecton Mar 23, 2020
d7e2119
Update xor.c
ioprojecton Mar 23, 2020
de5446d
Update xor.c
ioprojecton Mar 23, 2020
c81e940
Update README.md
ioprojecton Mar 27, 2020
f684d89
Update README.md
ioprojecton Mar 27, 2020
754ae6b
Update README.md
ioprojecton Mar 27, 2020
f0a19e6
Corrected not working solution
ioprojecton Mar 28, 2020
2ec6434
Update README.md
ioprojecton Mar 28, 2020
aefbda6
Update README.md
ioprojecton Mar 28, 2020
fe321ad
Update README.md
ioprojecton Mar 28, 2020
ba862ea
Update 2.c
ioprojecton Mar 28, 2020
8b41916
solution with file
ioprojecton Mar 28, 2020
f0ecffd
solution with stdin stdout
ioprojecton Mar 28, 2020
efb5cbf
Update 2c1.c
ioprojecton Mar 29, 2020
c22508e
one liner
ioprojecton Jul 25, 2021
544eef6
Update 14.c
ioprojecton Jul 29, 2021
2c94bb2
Update README.md
ioprojecton Jul 30, 2021
47463f7
Update README.md
ioprojecton Jul 30, 2021
5185c92
Update README.md
ioprojecton Jul 30, 2021
a6e3e96
Update README.md
ioprojecton Jul 30, 2021
68912a9
Update README.md
ioprojecton Jul 30, 2021
37e9d6b
Update README.md
ioprojecton Jul 30, 2021
30a6435
Update README.md
ioprojecton Jul 30, 2021
2e9f9c4
Update README.md
ioprojecton Jul 30, 2021
7f25a71
Update README.md
ioprojecton Jul 30, 2021
3d8f970
Update README.md
ioprojecton Jul 30, 2021
e26079c
Update README.md
ioprojecton Jul 31, 2021
a334468
Update 1.c
ioprojecton Aug 2, 2021
7c0fe3f
Update 6.c
ioprojecton Aug 3, 2021
be0f053
Update README.md
ioprojecton Aug 4, 2021
f580f00
Update README.md
ioprojecton Aug 4, 2021
b9af786
Update README.md
ioprojecton Aug 6, 2021
3cf6d7e
Update README.md
ioprojecton Aug 6, 2021
d032d54
Update README.md
ioprojecton Aug 6, 2021
0263413
Update README.md
ioprojecton Aug 6, 2021
c764adb
Update README.md
ioprojecton Aug 6, 2021
f5c0831
Update README.md
ioprojecton Aug 6, 2021
2618d59
Update README.md
ioprojecton Aug 7, 2021
fa68801
Update README.md
ioprojecton Aug 7, 2021
4c84a30
Update 2.c
ioprojecton Aug 7, 2021
776890a
Update 2.c
ioprojecton Aug 7, 2021
9b6cda7
Update README.md
ioprojecton Aug 9, 2021
8baf533
Update README.md
ioprojecton Aug 9, 2021
56afef1
Update README.md
ioprojecton Aug 9, 2021
19beaf5
Update README.md
ioprojecton Aug 9, 2021
6674c38
Update README.md
ioprojecton Aug 10, 2021
ab70ed0
Update README.md
ioprojecton Aug 10, 2021
235c05b
Update README.md
ioprojecton Aug 10, 2021
8a02c47
Update README.md
ioprojecton Aug 10, 2021
1e9a9fb
Update README.md
ioprojecton Aug 10, 2021
ad46693
Update README.md
ioprojecton Aug 11, 2021
744631c
Update README.md
ioprojecton Aug 11, 2021
c310b97
Update README.md
ioprojecton Aug 11, 2021
7a023d1
Update README.md
ioprojecton Aug 12, 2021
d0c1554
Update reverse.c
ioprojecton Aug 15, 2021
8ffe824
Update sum.c
ioprojecton Aug 15, 2021
e66d98c
Update 6.c
ioprojecton Aug 15, 2021
104ea47
Update 8.c
ioprojecton Aug 15, 2021
671ecd0
Update 9.c
ioprojecton Aug 16, 2021
6da037e
Update 10.c
ioprojecton Aug 16, 2021
b216e81
Update 11.c
ioprojecton Aug 18, 2021
b3c1b08
Update 12.c
ioprojecton Aug 18, 2021
2f4f58e
Update 13.c
ioprojecton Aug 18, 2021
b66689e
Update 16.c
ioprojecton Aug 19, 2021
86ee997
Update 17.c
ioprojecton Aug 19, 2021
f92e185
Update 17.c
ioprojecton Aug 19, 2021
a48c11b
Update 18.c
ioprojecton Aug 19, 2021
4894594
Update 18.c
ioprojecton Aug 19, 2021
923a81c
Update README.md
ioprojecton Aug 30, 2021
b802af8
doing some tests
ioprojecton Mar 25, 2022
3c776e3
deleted test file
ioprojecton Mar 25, 2022
9ba1f40
Update 1.c
ioprojecton Apr 11, 2022
9bdc235
Update 6.c
ioprojecton Apr 11, 2022
8769205
Update 7.c
ioprojecton Apr 11, 2022
8e4460c
Update 7.c
ioprojecton Apr 11, 2022
2023ef7
Update 9.c
ioprojecton Apr 13, 2022
69a3b6d
Update 9.c
ioprojecton Apr 13, 2022
8dd134d
Update 9.c
ioprojecton Apr 13, 2022
66b2256
Update 11.c
ioprojecton Apr 15, 2022
4b762b5
Update 11.c
ioprojecton Apr 15, 2022
13f22e3
Update 12.c
ioprojecton Apr 15, 2022
edafbea
Update 13.c
ioprojecton Apr 15, 2022
6e2c0b2
Update 14.c
ioprojecton Apr 16, 2022
4508e7e
Update 15.c
ioprojecton Apr 17, 2022
dbe3361
Update 16.c
ioprojecton Apr 17, 2022
93f8cd7
Update 4.c
ioprojecton Apr 18, 2022
2d7acd1
Update 4.c
ioprojecton Apr 18, 2022
ffbeaa9
Update 6.c
ioprojecton Apr 19, 2022
078b9f4
Update 6.c
ioprojecton Apr 21, 2022
468fb10
Update 1.c
ioprojecton Apr 23, 2022
029a34d
Update 2.c
ioprojecton Apr 24, 2022
902ac2a
Update 2.c
ioprojecton Apr 24, 2022
3d876a4
Update 1.c
ioprojecton Apr 27, 2022
9836ba7
Update 6.c
ioprojecton Apr 28, 2022
a5b0c7d
Update 7.c
ioprojecton Apr 28, 2022
bd46315
Update 7.c
ioprojecton Apr 28, 2022
74e6ec2
Update 7.c
ioprojecton Apr 28, 2022
847fef6
Update 9.c
ioprojecton Apr 29, 2022
99c7afd
Update 12.c
ioprojecton Apr 29, 2022
dfc471d
Update 13.c
ioprojecton Apr 29, 2022
5d27a5c
Update 14.c
ioprojecton Apr 30, 2022
000d1c0
Update 14.c
ioprojecton Apr 30, 2022
f62d20c
Update 15.c
ioprojecton Apr 30, 2022
722480e
Update 16.c
ioprojecton May 1, 2022
452b47d
Update 17.c
ioprojecton May 1, 2022
465b333
No need for make_empty()
ioprojecton May 19, 2022
13760ae
No need for make_empty()
ioprojecton May 19, 2022
5f6e0dc
memory leak bugfix
ioprojecton May 28, 2022
8c95ddc
added another solution
ioprojecton May 28, 2022
b2c00c7
undid changes
ioprojecton May 28, 2022
8fc1bb2
added another solution
ioprojecton May 28, 2022
6ccd8da
Update 1.c
ioprojecton May 28, 2022
337b700
Update 1.c
ioprojecton May 28, 2022
8639de7
added another solution
ioprojecton May 29, 2022
a727594
added another solution
ioprojecton May 29, 2022
a11dcb9
added another solution
ioprojecton May 29, 2022
8e25187
Update README.md
ioprojecton May 31, 2022
d65e4fc
added another solution
ioprojecton Jun 1, 2022
5411b0e
added another solution
ioprojecton Jun 2, 2022
b732c11
got rid of 1 extra statement
ioprojecton Jun 2, 2022
8936740
Update 6.c
ioprojecton Jun 2, 2022
b3b99f2
added one more solution
ioprojecton Dec 29, 2024
cf54f93
Update 14.c
ioprojecton Dec 29, 2024
0e995ca
Update 16.c
ioprojecton Dec 30, 2024
6cd908d
Update README.md
ioprojecton Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 08/exercises/11/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ for (i = 0; i < 8; i++) {
}
}
```

### Solution2
```c
char checker_board [8][8];
for (unsigned char i =0; i<8; i++)
for (unsigned char j = 0; j<8; checker_board[i][j] = !((i+j++)%2)? 'B': 'R');
```
15 changes: 15 additions & 0 deletions 08/projects/01/1.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,18 @@ int main(void) {
printf("\n");
return 0;
}

//how about this?
bool digit_seen[10] = {false};
int digit;
long n;

printf("Enter a number: ");
scanf("%ld", &n);
printf("repeated digits: ");
while (n > 0) {
digit = n % 10;
if (digit_seen[digit]) printf("%d ",digit);
digit_seen[digit] = true;
n /= 10;
}
59 changes: 28 additions & 31 deletions 08/projects/03/3.c
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
/* Checks numbers for repeated digits */

#include <stdbool.h> /* C99 only */
#include <stdio.h>

int main(void) {

int digit, i, occurrences[10] = {0};
long n;

printf("Enter a number: ");
scanf("%ld", &n);

if (n <= 0) {
printf("Digit:\t\t 0 1 2 3 4 5 6 7 8 9\n");
printf("Occurrences:\t 0 0 0 0 0 0 0 0 0 0\n");
}

while (n > 0) {
while (n > 0) {
digit = n % 10;
occurrences[digit]++;
n /= 10;
}

printf("Digit:\t\t 0 1 2 3 4 5 6 7 8 9\n");
printf("Occurrences:\t");

for (i = 0; i < 10; i++) {
printf("%2d ", occurrences[i]);
occurrences[i] = 0;
}
printf("\nEnter a number: ");
scanf("%ld", &n);
}
return 0;

int main(void)
{
unsigned char my_array[10];

long n;

long b;

for(unsigned char i=0;i<10;my_array[i++]=0);

printf("Enter numbers ... enter 0 to terminate: ");

do{

scanf("%ld", &b);
n=b;
for(;n;my_array[n%10]++,n/=10);

}while(b>0);

printf("0 1 2 3 4 5 6 7 8 9 10\n");

for(unsigned char i=0;i<10;printf("%d ",my_array[i++]));

return 0;
}

34 changes: 34 additions & 0 deletions 08/projects/06/6.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,37 @@ int main(void) {

return 0;
}

//How about this?
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#define MAX_SIZE 100
int main(void)
{

char message[MAX_SIZE]={0};

printf("Enter message: ");

char c;

unsigned char counter=0;

while((c=toupper(getchar()))!='\n' && counter<MAX_SIZE){

switch(c){
case 'A': message[counter++]='4';break;
case 'B': message[counter++]='8';break;
case 'E': message[counter++]='3';break;
case 'I': message[counter++]='1';break;
case 'O': message[counter++]='0';break;
case 'S': message[counter++]='5';break;
default: message[counter++]=c;break;
}

}
printf("Translated message: %s!!!!!!!!!!\n",message);
return 0;
}
90 changes: 66 additions & 24 deletions 08/projects/07/7.c
Original file line number Diff line number Diff line change
@@ -1,38 +1,80 @@
#include <stdio.h>
#include <stdlib.h>

int main(void) {
#define rows 5
#define cols 5

int i, j, temp_total;
int n[5][5];
int main()
{
int array[rows][cols];

for (i = 0; i < 5; i++) {
printf("Enter row %d: ", i + 1);
unsigned char row_sum=0;

for (j = 0; j < 5; j++) {
scanf("%d", &n[i][j]);
}
unsigned char col_sum=0;


for(unsigned char i=0;i<rows;i++){
printf("enter row %d:",i+1);

unsigned char b=0;

while(b<5) scanf("%d",&array[i][b++]);

}

printf("Row totals: ");
for(unsigned char i=0;i<5;i++){

for(unsigned char b=0;b<5;b++){
row_sum+=array[i][b];
}
printf("%2d ",row_sum);
row_sum=0;
}
putchar('\n');

printf("Row totals: ");
printf("Col totals: ");
for(unsigned char i=0;i<5;i++){

for (i = 0; i < 5; i++) {
temp_total = 0;
for (j = 0; j < 5; j++) {
temp_total += n[i][j];
}
printf("%d ", temp_total);
for(unsigned char b=0;b<5;b++){
col_sum+=array[b][i];
}
printf("%2d ",col_sum);
col_sum=0;
}
putchar('\n');
return 0;
}

printf("\nColumn totals: ");
for (i = 0; i < 5; i++) {
temp_total = 0;
for (j = 0; j < 5; j++) {
temp_total += n[j][i];
//how about this?
#include <stdio.h>

#define ROWS 5
#define COLS 5

int main(void)
{
int array[ROWS][COLS]={0};
int row_sum[ROWS]={0};
int col_sum[COLS]={0};

for(int i=0;i<ROWS && printf("Enter row %d:",i+1);i++)
for(int b=0;b<ROWS;scanf(" %d",&array[i][b++]));

printf("Row totals: ");
for(int i=0;i<ROWS;){
for(int b=0;b<ROWS;){
row_sum[i]+=array[i][b];
col_sum[i]+=array[b++][i];
}
printf("%d ", temp_total);
}
printf("%d ",row_sum[i++]);
}

printf("\n");
printf("\ncol totals: ");

return 0;
for(int i=0;i<ROWS;printf("%d ",col_sum[i++]));

putchar('\n');

return 0;
}
78 changes: 43 additions & 35 deletions 08/projects/08/8.c
Original file line number Diff line number Diff line change
@@ -1,48 +1,56 @@
#include <stdio.h>
#include <stdlib.h>

int main(void) {
#define rows 5
#define cols 5

int i, j, temp_total, high, low;
int n[5][5];
int main()
{
int array[rows][cols];

for (i = 0; i < 5; i++) {
printf("Enter quiz grades for student %d: ", i + 1);
unsigned char student_total_score=0;

for (j = 0; j < 5; j++) {
scanf("%d", &n[i][j]);
}
}
unsigned char col_sum=0;

printf("\n");
for(unsigned char i=0;i<rows;i++){
printf("Grades for Student %d:",i+1);

for (i = 0; i < 5; i++) {
printf("\nTotal and average score for student %d: ", i + 1);
temp_total = 0;
for (j = 0; j < 5; j++) {
temp_total += n[i][j];
}
printf("%d %.2f", temp_total, (double) temp_total / 5);
}
unsigned char b=0;

printf("\n");

for (i = 0; i < 5; i++) {
printf("\nAverage, high and low scores for quiz %d: ", i + 1);
temp_total = 0;
high = low = n[0][i];

for (j = 0; j < 5; j++) {
temp_total += n[j][i];
if (n[j][i] > high)
high = n[j][i];
if (n[j][i] < low)
low = n[j][i];
}
printf("%f %d %d", (double) temp_total / 5, high, low);
}
while(b<5) scanf("%d",&array[i][b++]);

}
putchar('\n');

printf("\n");
for(unsigned char i=0;i<5;i++){
printf("Total score for Student%d: ",i+1);

for(unsigned char b=0;b<5;b++){
student_total_score+=array[i][b];
}
printf("%d ",student_total_score);
printf("Average Score %.2f ",(float)student_total_score/rows);
putchar('\n');
student_total_score=0;
}
printf("\n\n");

unsigned char low=255;
unsigned char high=0;

for(unsigned char i=0;i<5;i++){
printf("Quiz %d: ",i+1);

for(unsigned char b=0;b<5;b++){
col_sum+=array[b][i];
if(array[b][i]<low) low=array[b][i];
if(array[b][i]>high) high=array[b][i];
}
printf("Average: %.2f Low: %d High: %d\n",(float)col_sum/cols,low,high);

col_sum=0;
}
putchar('\n');

return 0;
}
Loading