Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
sameis
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8781be09
authored
Nov 21, 2017
by
sameis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tere
parent
a7055319
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
PR12/PR12
PR12/PR12.c
PR12/PR12.o
PR12/PR12
0 → 100755
View file @
8781be09
File added
PR12/PR12.c
0 → 100644
View file @
8781be09
#include <stdio.h>
#include <math.h>
int
arvSisse
(
char
*
);
int
kontroll
(
int
,
int
);
void
kupuurid
(
int
[][
2
],
int
,
int
[]);
void
tulValja
(
int
[][
2
],
int
);
int
arvSisse
(
char
*
lause
)
{
int
kogus
=
0
;
printf
(
"%s
\n
"
,
lause
);
scanf
(
"%d"
,
&
kogus
);
return
kogus
;
}
void
kupuurid
(
int
kupuuridkogus
[][
2
],
int
kogus
,
int
out
[])
{
int
k
=
0
;
int
kupArv
=
arvSisse
(
"Mitu erinevat kupuuri on?
\n
"
);
int
kupuurid
[
kupArv
][
2
];
while
(
k
<
kupArv
)
{
kupuurid
[
k
][
0
]
=
arvSisse
(
"Sisesta kupuuri vaartus:
\n
"
);
kupuurid
[
k
][
1
]
=
arvSisse
(
"Sisesta olemasolevate kupuuride arv:
\n
"
);
k
++
;
}
while
(
kogus
>
0
)
//kupride kontroll
{
if
(
kogus
-
kupuurid
[
k
][
0
]
>
kupuurid
[
kupArv
][
0
]
{
if
(
kupuurid
[
k
][
1
]
>
0
)
{
kogus
-=
kupuurid
[
k
][
0
];
out
[
k
]
++
;
if
(
k
>
0
)
{
k
--
;
}
}
else
{
if
(
k
<
kupArv
)
{
k
++
;
}
else
{
printf
(
"Kupuure ei jatku!!!
\n
"
);
}
}
}
}
}
void
tulValja
(
int
kupuuridkogus
[][
2
],
int
kupArv
,
int
out
[])
{
int
kogus
=
0
;
for
(
i
=
0
;
i
<
kupArv
;
i
++
)
{
if
(
out
[
i
]
>
0
)
{
printf
(
"%dx%d
\n
"
,
out
[
i
],
kupuurid
[
i
]);
kogus
+=
out
[
i
]
*
kupuurid
[
i
];
}
}
printf
(
"%d
\n
"
,
kogus
);
}
int
main
(
void
)
{
int
kupArv
;
int
kupArv
=
(
"Erinevate kupuuride arv: "
);
int
out
[
kupArv
];
tulValja
(
kupuuridkogus
,
kupArv
,
out
);
kupuurid
(
kupuuridkogus
,
kogus
,
out
);
return
0
;
}
PR12/PR12.o
0 → 100644
View file @
8781be09
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment