Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
controle_prog_seq_2
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
Show more breadcrumbs
brian.crocoll
controle_prog_seq_2
Commits
229c6f29
Commit
229c6f29
authored
2 years ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
ex3
parent
4cf28391
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ex3/main.c
+99
-2
99 additions, 2 deletions
ex3/main.c
with
99 additions
and
2 deletions
ex3/main.c
+
99
−
2
View file @
229c6f29
#include
<stdio.h>
#include
<stdlib.h>
int
main
(){
typedef
struct
_element
{
int
data
;
struct
_element
*
next
;
}
element
;
void
cl_push
(
element
*
head
,
element
*
new_elem
,
int
data
){
element
*
current
=
head
;
while
(
current
->
next
!=
NULL
){
current
=
current
->
next
;
}
new_elem
->
data
=
data
;
new_elem
->
next
=
NULL
;
current
->
next
=
new_elem
;
}
void
cl_insert_at
(
element
*
head
,
element
*
new_elem
,
int
val
,
uint
index
){
element
*
current
=
head
;
for
(
uint
i
=
0
;
i
<
index
;
i
++
)
{
element
*
next
=
current
->
next
;
if
(
next
==
NULL
){
return
;
}
current
=
next
;
}
element
*
next
=
current
->
next
;
current
->
next
=
new_elem
;
new_elem
->
next
=
next
;
new_elem
->
data
=
val
;
}
void
cl_remove_at
(
element
*
head
,
uint
index
){
element
*
current
=
head
;
for
(
uint
i
=
0
;
i
<
index
;
i
++
)
{
element
*
next
=
current
->
next
;
if
(
next
==
NULL
){
return
;
}
current
=
next
;
}
element
*
next
=
current
->
next
;
element
*
n_next
=
next
->
next
;
current
->
data
=
next
->
data
;
current
->
next
=
n_next
;
}
int
paskal
(
int
row
,
int
col
){
if
(
col
==
0
){
return
1
;
}
else
if
(
row
==
0
){
return
0
;
}
return
(
paskal
(
row
-
1
,
col
)
+
paskal
(
row
-
1
,
col
-
1
));
}
void
cl_paskal
(
element
*
head
,
int
row
){
element
**
list
=
(
element
**
)
malloc
(
row
*
sizeof
(
element
*
));
for
(
int
i
=
0
;
i
<
row
;
i
++
){
list
[
i
]
=
(
element
*
)
malloc
(
row
*
sizeof
(
element
));
}
for
(
int
i
=
1
;
i
<
row
;
i
++
)
{
cl_push
(
head
,
list
[
i
],
paskal
(
row
,
i
));
}
element
lastElem
;
cl_push
(
head
,
&
lastElem
,
1
);
element
*
index
=
head
;
while
(
index
!=
NULL
){
printf
(
"%d "
,
index
->
data
);
index
=
index
->
next
;
}
printf
(
"
\n
"
);
for
(
int
i
=
0
;
i
<
row
;
i
++
){
free
(
list
[
i
]);
}
free
(
list
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
<
2
||
argc
>=
3
){
return
-
1
;
}
int
line
=
atoi
(
argv
[
1
]);
element
first
=
{.
data
=
1
,
.
next
=
NULL
};
element
*
head
=
&
first
;
cl_paskal
(
head
,
line
);
return
0
;
}
\ No newline at end of file
}
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