Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prog_exam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
boris.stefanov
prog_exam
Commits
40b9a402
Commit
40b9a402
authored
3 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Patches
Plain Diff
ADD: 1 done, 4 done, 2 works, 3 good start
parent
fdce8868
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
ex1/ex1.c
+14
-0
14 additions, 0 deletions
ex1/ex1.c
ex2/ex2.c
+104
-0
104 additions, 0 deletions
ex2/ex2.c
ex3/ex3.c
+108
-0
108 additions, 0 deletions
ex3/ex3.c
ex4/ex4.c
+21
-0
21 additions, 0 deletions
ex4/ex4.c
with
247 additions
and
0 deletions
ex1/ex1.c
+
14
−
0
View file @
40b9a402
...
@@ -5,5 +5,19 @@
...
@@ -5,5 +5,19 @@
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
bool
first
=
true
;
int
decnum
=
0
;
int
dectot
=
0
;
int
prev
,
next
;
scanf
(
"%d"
,
&
prev
);
for
(
int
i
=
1
;
i
<
8
;
++
i
)
{
scanf
(
"%d"
,
&
next
);
if
(
next
<
prev
)
{
++
decnum
;
dectot
+=
(
prev
-
next
);
}
prev
=
next
;
}
printf
(
"
\n
%d %d
\n\n
"
,
decnum
,
dectot
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
This diff is collapsed.
Click to expand it.
ex2/ex2.c
+
104
−
0
View file @
40b9a402
...
@@ -4,6 +4,110 @@
...
@@ -4,6 +4,110 @@
#include
<stdlib.h>
#include
<stdlib.h>
#define INSERT_VALUE 0
typedef
struct
_link
{
int
value
;
struct
_link
*
next
;
}
elem
;
typedef
struct
_list
{
elem
*
head
;
}
list
;
list
list_create
()
{
list
ll
;
ll
.
head
=
NULL
;
return
ll
;
}
void
list_destroy
(
list
*
ll
)
{
elem
*
e
=
ll
->
head
;
while
(
ll
->
head
!=
NULL
)
{
ll
->
head
=
ll
->
head
->
next
;
free
(
e
);
e
=
ll
->
head
;
}
}
void
list_push
(
list
*
ll
,
const
int
v
)
{
elem
*
e
=
malloc
(
sizeof
(
elem
));
e
->
value
=
v
;
e
->
next
=
ll
->
head
;
ll
->
head
=
e
;
}
void
list_insert
(
list
*
ll
,
const
int
n
,
const
int
v
)
{
if
(
n
<
0
)
{
return
;
}
elem
*
e
=
malloc
(
sizeof
(
elem
));
e
->
value
=
v
;
e
->
next
=
NULL
;
if
(
0
==
n
)
{
e
->
next
=
ll
->
head
;
ll
->
head
=
e
;
}
else
{
int
count
=
1
;
elem
*
prev
=
ll
->
head
;
while
(
count
<
n
)
{
if
(
NULL
==
prev
->
next
)
{
return
;
}
prev
=
prev
->
next
;
++
count
;
}
elem
*
follow
=
prev
->
next
;
e
->
next
=
follow
;
prev
->
next
=
e
;
}
}
void
list_remove
(
list
*
ll
,
const
int
n
)
{
if
(
n
<
0
)
{
return
;
}
if
(
0
==
n
)
{
elem
*
e
=
ll
->
head
;
ll
->
head
=
ll
->
head
->
next
;
free
(
e
);
}
else
{
int
count
=
1
;
elem
*
prev
=
ll
->
head
;
elem
*
e
=
prev
->
next
;
while
(
count
<
n
)
{
if
(
NULL
==
e
)
{
return
;
}
prev
=
e
;
e
=
e
->
next
;
++
count
;
}
if
(
e
!=
NULL
)
{
prev
->
next
=
e
->
next
;
}
else
{
prev
->
next
=
NULL
;
}
free
(
e
);
}
}
void
list_print
(
const
list
*
ll
)
{
elem
*
e
=
ll
->
head
;
while
(
e
!=
NULL
)
{
printf
(
"%d"
,
e
->
value
);
if
(
e
->
next
!=
NULL
)
{
printf
(
" "
);
}
e
=
e
->
next
;
}
printf
(
"
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
int
n
;
list
ll
=
list_create
();
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
scanf
(
"%d"
,
&
n
);
list_push
(
&
ll
,
n
);
}
int
i
,
r
;
scanf
(
"%d"
,
&
i
);
scanf
(
"%d"
,
&
r
);
printf
(
"
\n
"
);
list_insert
(
&
ll
,
i
,
INSERT_VALUE
);
list_print
(
&
ll
);
list_remove
(
&
ll
,
r
);
list_print
(
&
ll
);
list_destroy
(
&
ll
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
This diff is collapsed.
Click to expand it.
ex3/ex3.c
+
108
−
0
View file @
40b9a402
...
@@ -3,7 +3,115 @@
...
@@ -3,7 +3,115 @@
#include
<stdint.h>
#include
<stdint.h>
#include
<stdlib.h>
#include
<stdlib.h>
typedef
struct
_link
{
int
value
;
struct
_link
*
next
;
}
elem
;
typedef
struct
_list
{
elem
*
head
;
}
list
;
list
list_create
()
{
list
ll
;
ll
.
head
=
NULL
;
return
ll
;
}
void
list_destroy
(
list
*
ll
)
{
elem
*
e
=
ll
->
head
;
while
(
ll
->
head
!=
NULL
)
{
ll
->
head
=
ll
->
head
->
next
;
free
(
e
);
e
=
ll
->
head
;
}
}
void
list_push
(
list
*
ll
,
const
int
v
)
{
elem
*
e
=
malloc
(
sizeof
(
elem
));
e
->
value
=
v
;
e
->
next
=
ll
->
head
;
ll
->
head
=
e
;
}
void
list_insert
(
list
*
ll
,
const
int
n
,
const
int
v
)
{
if
(
n
<
0
)
{
return
;
}
elem
*
e
=
malloc
(
sizeof
(
elem
));
e
->
value
=
v
;
e
->
next
=
NULL
;
if
(
0
==
n
)
{
e
->
next
=
ll
->
head
;
ll
->
head
=
e
;
}
else
{
int
count
=
1
;
elem
*
prev
=
ll
->
head
;
while
(
count
<
n
)
{
if
(
NULL
==
prev
->
next
)
{
return
;
}
prev
=
prev
->
next
;
++
count
;
}
elem
*
follow
=
prev
->
next
;
e
->
next
=
follow
;
prev
->
next
=
e
;
}
}
void
list_remove
(
list
*
ll
,
const
int
n
)
{
if
(
n
<
0
)
{
return
;
}
if
(
0
==
n
)
{
elem
*
e
=
ll
->
head
;
ll
->
head
=
ll
->
head
->
next
;
free
(
e
);
}
else
{
int
count
=
1
;
elem
*
prev
=
ll
->
head
;
elem
*
e
=
prev
->
next
;
while
(
count
<
n
)
{
if
(
NULL
==
e
)
{
return
;
}
prev
=
e
;
e
=
e
->
next
;
++
count
;
}
if
(
e
!=
NULL
)
{
prev
->
next
=
e
->
next
;
}
else
{
prev
->
next
=
NULL
;
}
free
(
e
);
}
}
void
list_print
(
const
list
*
ll
)
{
elem
*
e
=
ll
->
head
;
while
(
e
!=
NULL
)
{
printf
(
"%d"
,
e
->
value
);
if
(
e
->
next
!=
NULL
)
{
printf
(
" "
);
}
e
=
e
->
next
;
}
printf
(
"
\n
"
);
}
// ^^^^ repris de la question 2
list
pascal
(
const
int
line
)
{
if
(
line
<=
1
)
{
list
ll
=
list_create
();
ll
.
push
(
1
);
return
ll
;
}
else
{
list
above
=
pascal
(
line
-
1
);
// rec
elem
*
e
=
above
.
head
;
list_ll
=
list_create
();
list_destroy
(
&
above
);
return
ll
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
int
line
;
scanf
(
"%d"
,
&
line
);
printf
(
"
\n
"
);
list
ll
=
pascal
(
line
);
list_print
(
&
ll
);
list_destroy
(
&
ll
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
This diff is collapsed.
Click to expand it.
ex4/ex4.c
+
21
−
0
View file @
40b9a402
...
@@ -5,5 +5,26 @@
...
@@ -5,5 +5,26 @@
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
size_t
size
=
0
;
scanf
(
"%lud"
,
&
size
);
int
px
[
size
];
int
py
[
size
];
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
scanf
(
"%d %d"
,
&
(
px
[
i
]),
&
(
py
[
i
]));
}
int
matrix
[
size
][
size
];
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
size_t
k
=
0
;
k
<
size
;
++
k
)
{
matrix
[
i
][
k
]
=
abs
(
px
[
i
]
-
px
[
k
])
+
abs
(
py
[
i
]
-
py
[
k
]);
}
}
printf
(
"
\n
"
);
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
size_t
k
=
0
;
k
<
size
;
++
k
)
{
printf
(
"%d"
,
matrix
[
i
][
k
]);
if
(
k
!=
(
k
-
1
))
{
printf
(
" "
);
}
}
printf
(
"
\n
"
);
}
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment