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
GitLab 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
75f8ba38
Commit
75f8ba38
authored
3 years ago
by
Boris Stefanovic
Browse files
Options
Downloads
Patches
Plain Diff
ADD: ex3, now everything works
parent
40b9a402
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ex3/ex3.c
+16
-50
16 additions, 50 deletions
ex3/ex3.c
with
16 additions
and
50 deletions
ex3/ex3.c
+
16
−
50
View file @
75f8ba38
...
...
@@ -34,50 +34,6 @@ void list_push(list* ll, const int v) {
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
)
{
...
...
@@ -94,19 +50,29 @@ void list_print(const list *ll) {
list
pascal
(
const
int
line
)
{
if
(
line
<=
1
)
{
list
ll
=
list_create
();
l
l
.
push
(
1
);
l
ist_
push
(
&
ll
,
1
);
return
ll
;
}
else
{
list
above
=
pascal
(
line
-
1
);
// rec
elem
*
e
=
above
.
head
;
list_ll
=
list_create
();
list_destroy
(
&
above
);
list
prevline
=
pascal
(
line
-
1
);
// rec
// 2l: on "triche" et on utilise la symmétrie du triangle
list
ll
=
list_create
();
list_push
(
&
ll
,
1
);
elem
*
above
=
prevline
.
head
;
elem
*
northwest
=
prevline
.
head
->
next
;
while
(
northwest
!=
NULL
)
{
// même trick
list_push
(
&
ll
,
above
->
value
+
northwest
->
value
);
above
=
northwest
;
northwest
=
northwest
->
next
;
}
list_push
(
&
ll
,
1
);
list_destroy
(
&
prevline
);
return
ll
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
()
{
int
line
;
scanf
(
"%d"
,
&
line
);
printf
(
"
\n
"
);
...
...
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