Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c7122a9
Learn C master
Sep 16, 2024
f91b21f
Update and clean up
Sep 16, 2024
b672aab
Update skill
Sep 16, 2024
29f5b36
code continute
Sep 16, 2024
570a0de
Format the program
Sep 16, 2024
e495d47
Update code Basic Algorithm
Sep 16, 2024
2734ee2
Update code
Sep 16, 2024
4e66648
Update Advance Algorithm
Sep 16, 2024
d45c780
Update code
Sep 16, 2024
8da5ea4
Update code
Sep 16, 2024
436db57
Clean up data
Sep 21, 2024
f08c49e
Upload code and pratice skill
Oct 5, 2024
74480f5
Get perfect target
Oct 5, 2024
6430dbb
Upload code swap value : Perfect target
Oct 5, 2024
f7636d7
Target perfect
Oct 5, 2024
27aec51
Clean up
Oct 5, 2024
3b4c5b3
Clean up
Oct 5, 2024
617a722
Upload the code
Oct 5, 2024
1cbbefc
build code pratice_arithmetic
Oct 6, 2024
277b993
Code for pratice caculation the time from A to B
Oct 6, 2024
f5e2b83
upload code pratice function
Oct 6, 2024
5d6a03b
pratice for example find the max value of 3 number
Oct 6, 2024
a34a61f
Upload code pratice convert seconds:
Oct 6, 2024
81e4ea3
Learning pointer
Oct 8, 2024
8f1b9b1
Update training session code
Oct 9, 2024
cc183a8
Training session pointer
Oct 9, 2024
0582821
Update code and clean code
Oct 9, 2024
005e604
Create struct file and learn
Oct 11, 2024
56c2d1f
update example for structs:
Oct 11, 2024
71999d2
Update code typedef
Oct 11, 2024
91eaba1
Exercise 1
Oct 11, 2024
1b8ac26
Update and pratice exerice 1
Oct 12, 2024
c6a7c54
clean up code
Oct 12, 2024
316172c
Add file Makefile
Oct 12, 2024
ffa7002
Pratice again
Oct 12, 2024
954fe02
Add file exercise 2
Oct 12, 2024
9bf3cee
Innovate add value of point
Oct 12, 2024
005f027
Clear
Oct 12, 2024
0509fe1
Update code arrayPoiny
Oct 12, 2024
bebee12
Create dynamic array
Oct 12, 2024
963e8e1
Clean up exercise 2
Oct 12, 2024
286b540
Update struct members
Oct 15, 2024
70babf7
Update code struct
Oct 15, 2024
9093553
Create struct operation
Oct 15, 2024
1cab176
Update code struct operation:
Oct 15, 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
5 changes: 5 additions & 0 deletions C_tutorial/C_Advance/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
defaults:
gcc -o test.o struct_operation.c

clean:
rm -f *.o
30 changes: 30 additions & 0 deletions C_tutorial/C_Advance/dynamicArraystruct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "stdio.h"
#include "stdlib.h"

typedef struct point {
int x;
int y;
}Point;

int main(){
Point pointArray[5];
printf("Enter the value first point x\n");
scanf("%d",&pointArray[0].x);
printf("Enter the value first point y\n");
scanf("%d",&pointArray[0].y);

for(int i=0;i<5;i++)
{
/*Enter code and innovate*/
printf("Enter the value point x string #%d \n",i+1);
scanf("%d",&pointArray[i].x);
printf("Enter the value point y string #%d \n",i+1);
scanf("%d",&pointArray[i].y);
}
for (int i=0;i<5;i++){
printf("Point #%d = (%d,%d)\n",i+1,pointArray[i].x,pointArray[i].y);
}
return 0;
}


38 changes: 38 additions & 0 deletions C_tutorial/C_Advance/exercise1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "stdio.h"
#include "stdlib.h"



/*Exercise 2 :
Write the function :
Function 1:-get the function variable and prints it information
Function 2:-responsible for getting input from user and return it*/
#include "stdio.h"
#include "stdlib.h"

typedef struct Point
{
/* data for struct point x,y */
int x;
int y;
}Point;

void printPoint(Point pt) {
printf("The value of x: %d\n",pt.x);
printf("The value of y: %d\n",pt.y);
}
Point pointview(){
Point pt;
printf("Enter the value of x:\n");
scanf("%d",&pt.x);
printf("Enter the value of y:\n");
scanf("%d",&pt.y);
return pt;
}
int main(){
Point pt1;
pt1 = pointview();
printPoint(pt1);

return 0;
}
29 changes: 29 additions & 0 deletions C_tutorial/C_Advance/pointer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "stdio.h"
#include "stdlib.h"

int main(){
int num1 = 50;
int num2 = 100;
int *ptrA, *ptrB;
printf("The value of number:%d\t%d\n",num1,num2);

/*tro den gia tri num1 num2 : pointer khai bao*/
ptrA = &num1;
ptrB = &num2;
printf("The value of num1,num2:%d\t%d\n",num1,num2);


*ptrA = *ptrA+1 ;
*ptrB = *ptrB+3;
printf("The value new the number1 and number2 %d\t%d\n",num1,num2);

ptrA = ptrB;
ptrB = ptrA;
printf("num1 %d \t, num2 %d\n",num1,num2);
printf("*ptrA = %d, *ptrB = %d \n",*ptrA,*ptrB);

num1 = *ptrB;
num2 = num1 - 3 ;
printf("num1 = %d,num2 = %d \n",num1,num2);
return 0;
}
22 changes: 22 additions & 0 deletions C_tutorial/C_Advance/pointer_advance.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "stdio.h"
#include "stdlib.h"

void findMaxMin(int num1, int num2,int *ptrA, int *ptrB){
if (num1>num2) {
*ptrA = num1;
*ptrB = num2;
}
else {
*ptrA = num2;
*ptrB = num1;
}
}
int main(){
int a = 10, b = 20;
int max,min;
findMaxMin(a,b,&max,&min);
printf("The value of max %d \n",max);
printf("The value of min %d \n",min);

return 0;
}
27 changes: 27 additions & 0 deletions C_tutorial/C_Advance/pointer_pratice.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// #include "stdio.h"
// #include "stdlib.h"


// int main(){
// int a = 5;
// int *p;
// p = &a;
// printf("%p \n",&a);
// printf("%p \n",p);
// printf("%d \n",a);
// printf("%d \n",*p);
// return 0;
// }

#include "stdio.h"
#include "stdlib.h"

int main(){
int grade1 = 80, grade2 = 100;
printf("value of grade1 : %d \n",grade1);
printf("value of grade2: %d \n",grade2);

printf("Address of the grade1 %p\n",&grade1);
printf("Address of the grade2 %p\n",&grade2);
return 0;
}
39 changes: 39 additions & 0 deletions C_tutorial/C_Advance/struct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "stdio.h"
#include "stdlib.h"

// struct point {
// int x;
// int y;
// };

// struct date
// {
// /*struct in day for using cusomized data */
// int day;
// int months;
// int year;
// };

/*typedef example */
typedef struct date{
int day;
int months;
int year;
}Date;
int main()
{
struct date graduteDate;
printf("Enter day:");
scanf("%d",&graduteDate.day);

printf("Enter months:");
scanf("%d",&graduteDate.months);

printf("Enter year:");
scanf("%d",&graduteDate.year);
printf("The my gradute day is (%d,%d,%d) \n",graduteDate.day,graduteDate.months,graduteDate.year);


return 0;
}

26 changes: 26 additions & 0 deletions C_tutorial/C_Advance/struct_members.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

typedef struct employee{
char name[10];
float age;
int id;
}Employee;

int main(){
Employee emp1;
Employee emp2 = {"Jake",25.4,123};

emp1 = emp2;
printf("Employee 1 is name %s\n",emp1.name);
printf("Employee 2 is name %s\n",emp2.name);

strcpy(emp1.name,"Join");
emp1.id = 456;

printf("Id of members %d\n",emp1.id);
printf("The name of members 1 %s\n",emp1.name);
return 0;

}
81 changes: 81 additions & 0 deletions C_tutorial/C_Advance/struct_operation.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

typedef struct point
{
int x;
int y;
}Point;

typedef struct employee
{
char name[10];
float age;
int id;
}Employee;

int equalPoints(Point p1, Point p2) // "Operation =="
{
if((p1.x == p2.x)&&(p1.y==p2.y)){
return 1;
}
else {
return 0;
}
}
int notEqualPoints(Point p1, Point p2) // "Operation !="
{
if((p1.x != p2.x)||(p1.y!=p2.y)){
return 1;
}
else {
return 0;
}
}

int equalAge(Employee e1,Employee e2)
{
if(e1.age == e2.age){
return 0;
}
else if (e1.age < e2.age) {
return -1;
}
else //e2.age > e1.age
return 1;
}

int equalName(Employee e1,Employee e2)
{
if(e1.name == e2.name){
return 0;
}
else if (e1.name < e2.name) {
return -1;
}
else //e2.age > e1.age
return 1;
}
int equalId(Employee e1,Employee e2)
{
if(e1.id == e2.id){
return 0;
}
else if (e1.id < e2.id) {
return -1;
}
else //e2.age > e1.age
return 1;
}

int main()
{
Point point1 = {2,4};
Point point2 = {3,5};
if (equalPoints(point1,point2) !=0) {
// Code related to the fact that the points are equal
printf("The struct is not equal\n");
}
return 0;
}
31 changes: 31 additions & 0 deletions C_tutorial/C_Advance/struct_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// #include "stdio.h"
// #include "stdlib.h"

// typedef struct point
// {
// int x;
// int y;
// }Point;

// int main()
// {
// Point p1;
// Point p2 = {5,7};
// Point p3 = {.x = 3, .y = 5};
// Point p4 = {.y = 10, .x =5};
// Point p5 = {.x=10};

// return 0;
// }

/*Write the function
- Function 1: get the point variable and print this information
- Function 2: responsible for getting a point input from the user and the return it*/
#include "stdio.h"
#include "stdlib.h"

int main()
{

return 0;
}
40 changes: 40 additions & 0 deletions C_tutorial/C_Advance/typedef.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "stdio.h"
#include "stdlib.h"



typedef struct date
{
int day;\
int months;
int year;
}Date;

void printDate(Date dt)
{
printf("Year = %d,Months = %d, Day =%d \n",dt.year,dt.months,dt.day);
}
Date inputDate(){
Date dt;
printf("Enter day:");
scanf("%d",&dt.day);

printf("Enter months");
scanf("%d",&dt.months);

printf("Enter year");
scanf("%d",&dt.year);
return dt;
}
int main()
{
Date graduteDate,todayDate;
graduteDate = inputDate();

todayDate = inputDate();
printDate(graduteDate);
printDate(todayDate);


return 0;
}
11 changes: 11 additions & 0 deletions C_tutorial/C_Algorithm/pratice1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "stdio.h"

int test(int x, int y) {
return x==y? (x+y)*3:(x+y);
};
// int test(int x,int y);
int main(){
printf("%d\n",test(1,2));
printf("%d\n",test(2,2));
return 0;
}
Loading