Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Enchente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
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
Vytor Calixto
Enchente
Commits
d9771a17
There was a problem fetching the pipeline summary.
Commit
d9771a17
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add função para ver mínimo e máximo de jogadas
parent
e6e8c8f2
Branches
Develop_copy_to_implement_acessibility_in_admin
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
main.c
+22
-2
22 additions, 2 deletions
main.c
with
24 additions
and
4 deletions
Makefile
+
2
−
2
View file @
d9771a17
...
@@ -11,7 +11,7 @@ test: main
...
@@ -11,7 +11,7 @@ test: main
./runTests.sh
./runTests.sh
main
:
main.c libs/jogador.o libs/tabuleiro.o libs/grafo.o libs/vertice.o libs/filha.o libs/lista.o libs/no.o
main
:
main.c libs/jogador.o libs/tabuleiro.o libs/grafo.o libs/vertice.o libs/filha.o libs/lista.o libs/no.o
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
$(
CC
)
$(
CFLAGS
)
-o
$@
$^
-lm
clean
:
clean
:
$(
RM
)
*
.o
$(
RM
)
*
.o
...
...
This diff is collapsed.
Click to expand it.
main.c
+
22
−
2
View file @
d9771a17
...
@@ -3,13 +3,14 @@
...
@@ -3,13 +3,14 @@
#include
<stdio.h>
#include
<stdio.h>
#include
<stdbool.h>
#include
<stdbool.h>
#include
<time.h>
#include
<time.h>
#include
<math.h>
#include
"libs/tabuleiro.h"
#include
"libs/tabuleiro.h"
#include
"libs/no.h"
#include
"libs/no.h"
#include
"libs/lista.h"
#include
"libs/lista.h"
#include
"libs/grafo.h"
#include
"libs/grafo.h"
#include
"libs/jogador.h"
#include
"libs/jogador.h"
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
Tblr
t
=
criaTblr
();
Tblr
t
=
criaTblr
();
// Aloca o tabuleiro em um único array em vez de um "array de arrays"
// Aloca o tabuleiro em um único array em vez de um "array de arrays"
if
(
!
leTblr
(
t
))
{
if
(
!
leTblr
(
t
))
{
...
@@ -17,6 +18,25 @@ int main() {
...
@@ -17,6 +18,25 @@ int main() {
return
-
1
;
return
-
1
;
}
}
// Se colocar UMA e APENAS UMA coisa depois do main
if
(
argc
==
2
)
{
// Calcula e imprime o número mínimo e máximo de jogadas
if
(
t
->
x
!=
t
->
y
)
{
puts
(
"Apenas funciona para tabuleiros quadrados"
);
}
else
{
// Max é 2n + sqrt(2k)n + k
double
max
=
2
*
(
t
->
x
)
+
(
sqrt
(
2
*
t
->
cores
))
*
(
t
->
x
)
+
t
->
cores
;
printf
(
"
\t
Número máximo de jogadas: %f
\n
"
,
max
);
// Min é válido para 2 <= k <= n²
// Min é sqrt(k - 1)n/2 - k/2
if
(
t
->
cores
>=
2
&&
t
->
cores
<=
(
t
->
x
*
t
->
x
))
{
double
n2
=
t
->
x
/
2
;
double
min
=
(
sqrt
(
t
->
cores
-
1
)
*
t
->
x
/
2
)
-
(
t
->
cores
/
2
);
printf
(
"
\t
Número mínimo de jogadas: %f
\n
"
,
min
);
}
}
}
//TODO imprimindo o tabuleiro
//TODO imprimindo o tabuleiro
// imprimeTblr(t);
// imprimeTblr(t);
...
...
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