rjeseno sve
This commit is contained in:
parent
012139ca02
commit
9821ee53c0
11 changed files with 85 additions and 19 deletions
|
|
@ -1 +1,5 @@
|
||||||
# marinlv2
|
# lv zadatci
|
||||||
|
|
||||||
|
ovaj projekt se **NE** kompajlira kao vs solucija, potrebno je (na windowsima) ga kompajlirati ovako:
|
||||||
|
|
||||||
|
cl /EHsc /nologo /W4 1-raznostranican.cpp & 1-raznostranican.exe
|
||||||
11
lv2/marinlv2/1-pravokutan.cpp
Normal file
11
lv2/marinlv2/1-pravokutan.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
float k1, k2;
|
||||||
|
std::cout << "unesi 2 katete: ";
|
||||||
|
std::cin >> k1 >> k2;
|
||||||
|
std::cout << "Hipotenuza je: " << sqrt(pow(k1, 2) + pow(k2, 2));
|
||||||
|
std::cout << "povrsina je: " << (k1 * k2) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
12
lv2/marinlv2/1-raznostranican.cpp
Normal file
12
lv2/marinlv2/1-raznostranican.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
//heron: https://en.wikipedia.org/wiki/Heron%27s_formula
|
||||||
|
//glasi: a=sqrt(s(s-a)(s-b)(s-c))
|
||||||
|
//operatori: *,/,sqrt
|
||||||
|
int main() {
|
||||||
|
double s1, s2, s3;
|
||||||
|
std::cout << "unesi 3 stranice:";
|
||||||
|
std::cin >> s1 >> s2 >> s3;
|
||||||
|
std::cout << "povrsina je: " << (s1 + s2 + s3) / 2;
|
||||||
|
|
||||||
|
}
|
||||||
BIN
lv2/marinlv2/1-raznostranican.exe
Normal file
BIN
lv2/marinlv2/1-raznostranican.exe
Normal file
Binary file not shown.
BIN
lv2/marinlv2/1.exe
Normal file
BIN
lv2/marinlv2/1.exe
Normal file
Binary file not shown.
5
lv2/marinlv2/2.cpp
Normal file
5
lv2/marinlv2/2.cpp
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
}
|
||||||
33
lv2/marinlv2/loto.cpp
Normal file
33
lv2/marinlv2/loto.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
const int BROJEVA = 7;
|
||||||
|
int izracunaj_dzoker(int arr[]) {
|
||||||
|
std::string fin = "";
|
||||||
|
for (int i = 0; i < BROJEVA-1; i++) {
|
||||||
|
fin+=(std::to_string(arr[i] % 10));
|
||||||
|
}
|
||||||
|
//std::reverse(fin.begin(), fin.end());
|
||||||
|
return std::stoi(fin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int zbroj_jedinica = 0;
|
||||||
|
int brojevi[BROJEVA] = { 0 };
|
||||||
|
std::cout << "unesi 7 brojeva lota" << std::endl;
|
||||||
|
for (int i = 0; i < BROJEVA; i++) {
|
||||||
|
std::cin >> brojevi[i];
|
||||||
|
//racunam odma, ne trebaju mi ostali prije nego sto izracunam
|
||||||
|
if (i == BROJEVA - 1) continue;
|
||||||
|
zbroj_jedinica += brojevi[i] % 10;
|
||||||
|
}
|
||||||
|
std::cout << zbroj_jedinica << std::endl;
|
||||||
|
|
||||||
|
std::cout << izracunaj_dzoker(brojevi)%101 << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
BIN
lv2/marinlv2/loto.exe
Normal file
BIN
lv2/marinlv2/loto.exe
Normal file
Binary file not shown.
|
|
@ -127,7 +127,11 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="marinlv2.cpp" />
|
<ClCompile Include="1-pravokutan.cpp" />
|
||||||
|
<ClCompile Include="1-raznostranican.cpp" />
|
||||||
|
<ClCompile Include="2.cpp" />
|
||||||
|
<ClCompile Include="loto.cpp" />
|
||||||
|
<ClCompile Include="pocetak.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,19 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="marinlv2.cpp">
|
<ClCompile Include="pocetak.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="1-pravokutan.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="2.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="1-raznostranican.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="loto.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
// marinlv2.cpp : This file contains the 'main' function. Program execution begins and ends there.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1. Nabrojite pet različitih jednostavnih tipova podataka u C++ programskom jeziku.:
|
1. Nabrojite pet različitih jednostavnih tipova podataka u C++ programskom jeziku.:
|
||||||
void, int, double, float, long
|
void, int, double, float, long
|
||||||
|
|
@ -28,14 +24,3 @@ sqrt, +, /
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
float k1, k2;
|
|
||||||
std::cout << "unesi 2 katete: ";
|
|
||||||
std::cin >> k1 >> k2;
|
|
||||||
std::cout << "Hipotenuza je: " << sqrt(pow(k1, 2) + pow(k2, 2));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue