rjeseno sve

This commit is contained in:
student 2025-10-03 12:05:37 +02:00
parent 012139ca02
commit 9821ee53c0
11 changed files with 85 additions and 19 deletions

View file

@ -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

View 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;
}

View 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;
}

Binary file not shown.

BIN
lv2/marinlv2/1.exe Normal file

Binary file not shown.

5
lv2/marinlv2/2.cpp Normal file
View file

@ -0,0 +1,5 @@
#include <iostream>
int main() {
}

33
lv2/marinlv2/loto.cpp Normal file
View 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

Binary file not shown.

View file

@ -127,7 +127,11 @@
</Link>
</ItemDefinitionGroup>
<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>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View file

@ -15,7 +15,19 @@
</Filter>
</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>
</ClCompile>
</ItemGroup>

View file

@ -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.:
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));
}