Updated name, removed norwegian characters
This commit is contained in:
31
Oving 2/Oving2Oppg1to4/Oving2Oppg1to4.sln
Normal file
31
Oving 2/Oving2Oppg1to4/Oving2Oppg1to4.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.271
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oving2Oppg1to4", "Oving2Oppg1to4\Oving2Oppg1to4.vcxproj", "{A1357224-B406-4023-A892-AA8D6CF3C409}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Debug|x64.Build.0 = Debug|x64
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Debug|x86.Build.0 = Debug|Win32
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Release|x64.ActiveCfg = Release|x64
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Release|x64.Build.0 = Release|x64
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A1357224-B406-4023-A892-AA8D6CF3C409}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8D537A7E-F206-4DF9-AAC9-BAB34073FA1F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
142
Oving 2/Oving2Oppg1to4/Oving2Oppg1to4/Oving2Oppg1to4.vcxproj
Normal file
142
Oving 2/Oving2Oppg1to4/Oving2Oppg1to4/Oving2Oppg1to4.vcxproj
Normal file
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{a1357224-b406-4023-a892-aa8d6cf3c409}</ProjectGuid>
|
||||
<RootNamespace>Oving2Oppg1to4</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>C:\Program Files\TDT4102\includes;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
233
Oving 2/Oving2Oppg1to4/Oving2Oppg1to4/main.cpp
Normal file
233
Oving 2/Oving2Oppg1to4/Oving2Oppg1to4/main.cpp
Normal file
@@ -0,0 +1,233 @@
|
||||
#include "std_lib_facilities.h"
|
||||
|
||||
#pragma region Oppgave 1 og 2
|
||||
|
||||
|
||||
void inputAndPrintInteger() {
|
||||
cout << "Skriv inn et tall: ";
|
||||
int input = 0;
|
||||
cin >> input;
|
||||
cout << "Du skrev: " << input << "\n";
|
||||
}
|
||||
|
||||
|
||||
int inputInteger() {
|
||||
cout << "Skriv inn et tall: ";
|
||||
int input = 0; cin >> input;
|
||||
return input;
|
||||
}
|
||||
|
||||
void inputIntegersAndPrintSum() {
|
||||
int a = inputInteger();
|
||||
int b = inputInteger();
|
||||
int number = a + b;
|
||||
cout << "Summen av tallene: " << number << "\n";
|
||||
}
|
||||
|
||||
bool IsOdd(int number) {
|
||||
if (number % 2)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void printHumanReadableTime(int seconds) {
|
||||
int minSek = 60, timeSek = pow(minSek, 2);
|
||||
int timer = seconds / timeSek;
|
||||
int timeLeft = seconds - timer * timeSek;
|
||||
int minutter = timeLeft / minSek;
|
||||
timeLeft = timeLeft - minutter * minSek;
|
||||
cout << timer << " timer, " << minutter << " minutter, " << timeLeft << " sekunder" << "\n";
|
||||
}
|
||||
|
||||
void inputIntegersUsingLoopAndPrintSum() {
|
||||
int sum = 0;
|
||||
int innlest = 0;
|
||||
while (true) {
|
||||
innlest = inputInteger();
|
||||
if (innlest == 0)
|
||||
break;
|
||||
sum += innlest;
|
||||
}
|
||||
cout << "Summen er: " << sum << "\n";
|
||||
}
|
||||
|
||||
double inputDouble() {
|
||||
double inndata = 0.0;
|
||||
cout << "Skriv inn et desimaltall: ";
|
||||
cin >> inndata;
|
||||
return inndata;
|
||||
}
|
||||
|
||||
void NOKtoEUR(double eurValue = 9.75) {
|
||||
double nok = inputDouble();
|
||||
while (nok < 0)
|
||||
{
|
||||
cout << "Tallet er negativt, skriv inn et positivt tall." << endl;
|
||||
nok = inputDouble();
|
||||
}
|
||||
cout << nok << " kroner er " << (nok / eurValue) << " euro." << endl;
|
||||
}
|
||||
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Oppgave 3
|
||||
|
||||
void Gangetabell(int width, int height) {
|
||||
string leng = std::to_string(width * height);
|
||||
for (int i = 1; i <= width; i++) {
|
||||
for (int j = 1; j <= height; j++) {
|
||||
cout << setw(leng.length() + 1) << i * j;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawGangetabell() {
|
||||
int width = 0, height = 0;
|
||||
cout << "Skriv inn bredden p<> gangetabellen: ";
|
||||
cin >> width;
|
||||
cout << "Skriv inn h<>yden p<> gangetabellen: ";
|
||||
cin >> height;
|
||||
Gangetabell(width, height);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Oppgave 4
|
||||
|
||||
double Discriminant(double a, double b, double c) {
|
||||
return pow(b, 2) - (4 * a * c);
|
||||
}
|
||||
|
||||
void PrintRealRoots(double a, double b, double c) {
|
||||
double disc = Discriminant(a, b, c);
|
||||
if (disc > 0) {
|
||||
double solved1 = (-b + sqrt(disc)) / (2 * a);
|
||||
double solved2 = (-b - sqrt(disc)) / (2 * a);
|
||||
cout << "The solutions are x_1 = " << solved1 << " and x_2 = " << solved2 << endl;
|
||||
}
|
||||
else if (disc == 0)
|
||||
cout << "The solution are x = " << (-b / (2 * a)) << endl;
|
||||
else if (disc < 0)
|
||||
cout << "There are no real solutions.";
|
||||
}
|
||||
|
||||
void SolveQuadradicEquation() {
|
||||
double a = 0, b = 0, c = 0;
|
||||
cout << "ax^2 + bx + c = 0" << endl;
|
||||
cout << "Enter a = ";
|
||||
cin >> a;
|
||||
cout << "Enter b = ";
|
||||
cin >> b;
|
||||
cout << "Enter c = ";
|
||||
cin >> c;
|
||||
PrintRealRoots(a, b, c);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Menu
|
||||
|
||||
bool menyFunc() {
|
||||
cout << "\nVelg funksjon:\n";
|
||||
cout << "(0) Avslutt\n";
|
||||
cout << "(1) Summer to tall\n";
|
||||
cout << "(2) Summer flere tall\n";
|
||||
cout << "(3) Konverter fra NOK til EURO\n";
|
||||
cout << "(4) Tegn gangetabell" << endl;
|
||||
cout << "(5) L<>s 2. gradsplynom" << endl;
|
||||
cout << "Angi valg (0-5): ";
|
||||
int valg = 0;
|
||||
cin >> valg;
|
||||
switch (valg)
|
||||
{
|
||||
case 0:
|
||||
return false;
|
||||
break;
|
||||
case 1:
|
||||
inputIntegersAndPrintSum();
|
||||
break;
|
||||
case 2:
|
||||
inputIntegersUsingLoopAndPrintSum();
|
||||
break;
|
||||
case 3:
|
||||
NOKtoEUR();
|
||||
break;
|
||||
case 4:
|
||||
DrawGangetabell();
|
||||
break;
|
||||
case 5:
|
||||
SolveQuadradicEquation();
|
||||
break;
|
||||
default:
|
||||
cout << "Tast inn et tall mellom 0 og 5. Pr<50>v igjen.\n";
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
||||
int main() {
|
||||
{
|
||||
/*
|
||||
// Oppgave 1a
|
||||
inputAndPrintInteger();
|
||||
|
||||
|
||||
// 1b
|
||||
int number = inputInteger();
|
||||
cout << "Du skrev: " << number << "\n";
|
||||
|
||||
// 1c
|
||||
cout << "\n\n1c\n";
|
||||
inputIntegersAndPrintSum();
|
||||
|
||||
// 1d - TEORI
|
||||
//
|
||||
//Jeg valgte inputInteger fordi den ikke printer tallet du skrev inn tilbake til skjermen.
|
||||
//
|
||||
|
||||
// 1e
|
||||
for (int i = 0; i < 16; i++) {
|
||||
cout << i << ": " << IsOdd(i) << "\n";
|
||||
}
|
||||
|
||||
// 1f
|
||||
printHumanReadableTime(10000);
|
||||
*/
|
||||
}
|
||||
|
||||
{
|
||||
/*
|
||||
// Oppgave 2a
|
||||
inputIntegersUsingLoopAndPrintSum();
|
||||
|
||||
// 2b - TEORI
|
||||
/*
|
||||
Dersom man velger <20> avslutte summing med 0, burde man bruke en "while"-l<>kke. Den kan fortsette i all evighet, siden den ikke krever noen start- og sluttverider.
|
||||
|
||||
Der du sier hvor mange summinger du <20>nsker er en "for"-l<>kke det beste, da kj<6B>rer den kun sp mange ganger du <20>nsker at den skal kj<6B>re
|
||||
*/
|
||||
/*
|
||||
// 2c
|
||||
cout << "Halvparten :" << inputDouble() / 2;
|
||||
*/
|
||||
//2d
|
||||
//NOKtoEUR();
|
||||
}
|
||||
|
||||
|
||||
#pragma region Oppgave 3 - Menysystem
|
||||
// a
|
||||
|
||||
while (menyFunc()) {}
|
||||
|
||||
//Gangetabell(14, 14);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user