refresh pages
This commit is contained in:
parent
7f81ef9f48
commit
4f3a700605
|
@ -40,7 +40,7 @@
|
||||||
<h2>1. Übersicht<a class="headerlink" href="#ubersicht" title="Permalink to this headline">¶</a></h2>
|
<h2>1. Übersicht<a class="headerlink" href="#ubersicht" title="Permalink to this headline">¶</a></h2>
|
||||||
<p>In diesem Praktikum erstellen Sie mehrere kleine C-Programme, in denen Sie Input- und Output-Funktionen der C Standard Library verwenden.</p>
|
<p>In diesem Praktikum erstellen Sie mehrere kleine C-Programme, in denen Sie Input- und Output-Funktionen der C Standard Library verwenden.</p>
|
||||||
<p>Arbeiten Sie in Zweiergruppen und diskutieren Sie ihre Lösungsansätze miteinander, bevor Sie diese umsetzen.</p>
|
<p>Arbeiten Sie in Zweiergruppen und diskutieren Sie ihre Lösungsansätze miteinander, bevor Sie diese umsetzen.</p>
|
||||||
<p>Bevor Sie mit den Programmieraufgaben beginnen, setzen Sie eine virtuelle Maschine mit der vorbereiteten Praktikumsumgebung auf.</p>
|
<p>Bevor Sie mit den Programmieraufgaben beginnen, setzen Sie eine virtuelle Maschine mit der vorbereiteten Praktikumsumgebung auf. Die entsprechende Anleitung finden Sie hier: <a class="reference external" href="https://github.zhaw.ch/SNP/snp-lab-env/blob/master/docs/Arbeitsumgebung_f%C3%BCr_die_Praktika.pdf">https://github.zhaw.ch/SNP/snp-lab-env/blob/master/docs/Arbeitsumgebung_f%C3%BCr_die_Praktika.pdf</a>.</p>
|
||||||
</section>
|
</section>
|
||||||
<hr class="docutils" />
|
<hr class="docutils" />
|
||||||
<section id="lernziele">
|
<section id="lernziele">
|
||||||
|
|
|
@ -1,245 +0,0 @@
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
|
||||||
|
|
||||||
<title>Lösungsskizzen — SNP Labs documentation</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
|
|
||||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
|
||||||
<script src="../_static/jquery.js"></script>
|
|
||||||
<script src="../_static/underscore.js"></script>
|
|
||||||
<script src="../_static/doctools.js"></script>
|
|
||||||
<link rel="index" title="Index" href="../genindex.html" />
|
|
||||||
<link rel="search" title="Search" href="../search.html" />
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
|
|
||||||
|
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
|
||||||
|
|
||||||
</head><body>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="document">
|
|
||||||
<div class="documentwrapper">
|
|
||||||
<div class="bodywrapper">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="body" role="main">
|
|
||||||
|
|
||||||
<section class="tex2jax_ignore mathjax_ignore" id="losungsskizzen">
|
|
||||||
<h1>Lösungsskizzen<a class="headerlink" href="#losungsskizzen" title="Permalink to this headline">¶</a></h1>
|
|
||||||
<section id="aufgabe-1">
|
|
||||||
<h2>Aufgabe 1<a class="headerlink" href="#aufgabe-1" title="Permalink to this headline">¶</a></h2>
|
|
||||||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>/**
|
|
||||||
* Tage Pro Monat
|
|
||||||
*
|
|
||||||
* Das Programm liest einen Monat (1-12) und ein Jahr (1600-2400) ein und
|
|
||||||
* gibt die Anzahl der Tage dieses Monats aus.
|
|
||||||
*
|
|
||||||
* @author Gerrit Burkert, Adaptation bazz
|
|
||||||
* @version 15-FEB-2013, 16-OCT-2017, 17-OCT-2019, 16-FEB-2022
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define ERROR_IN_MONTH 1
|
|
||||||
#define ERROR_IN_YEAR 2
|
|
||||||
|
|
||||||
///// Student Code
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Konstante Werte fuer die Monate
|
|
||||||
// ===============================
|
|
||||||
|
|
||||||
enum { JAN=1, FEB, MAR, APR, MAI, JUN, JUL, AUG, SEP, OKT, NOV, DEZ };
|
|
||||||
|
|
||||||
|
|
||||||
// Eingabe pruefen (0 ist vom atoi als Fehelcode verwendet und darf nicht verwendet werden)
|
|
||||||
// ===============
|
|
||||||
|
|
||||||
int gibIntWert(char *name, int von, int bis) {
|
|
||||||
|
|
||||||
int wert;
|
|
||||||
char wertS[20]; //
|
|
||||||
|
|
||||||
do {
|
|
||||||
printf("%s: ", name);
|
|
||||||
fgets(wertS, 20, stdin);
|
|
||||||
wert = atoi(wertS);
|
|
||||||
if (wert < von || wert > bis) {
|
|
||||||
printf("Der Wert muss zwischen %d und %d sein.\n", von, bis);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while(1);
|
|
||||||
return wert;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Schaltjahr bestimmen
|
|
||||||
// ====================
|
|
||||||
|
|
||||||
int istSchaltjahr(int jahr){
|
|
||||||
|
|
||||||
if ( (jahr % 400 == 0) || ( (jahr %100 != 0) && (jahr % 4 ==0) ) )
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Berechnung Anzahl Tage pro Monat
|
|
||||||
// ================================
|
|
||||||
|
|
||||||
int tageProMonat(int jahr, int monat) {
|
|
||||||
|
|
||||||
int anzTage;
|
|
||||||
|
|
||||||
// Tage pro Monat bestimmen
|
|
||||||
switch (monat) {
|
|
||||||
|
|
||||||
// Monate mit 31 Tagen
|
|
||||||
case JAN: case MAR: case MAI: case JUL: case AUG: case OKT: case DEZ:
|
|
||||||
anzTage = 31;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Monate mit 30 Tagen
|
|
||||||
case APR: case JUN: case SEP: case NOV:
|
|
||||||
anzTage = 30;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Februar: 28 oder 29 Tage
|
|
||||||
case FEB:
|
|
||||||
|
|
||||||
if (istSchaltjahr(jahr)) {
|
|
||||||
anzTage = 29;
|
|
||||||
} else {
|
|
||||||
anzTage = 28;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return anzTage;
|
|
||||||
}
|
|
||||||
|
|
||||||
///// END Student Code
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
|
||||||
|
|
||||||
int monat, jahr;
|
|
||||||
|
|
||||||
// Monat einlesen und Bereich ueberpruefen
|
|
||||||
monat = gibIntWert("Monat", 1, 12);
|
|
||||||
jahr = gibIntWert("Jahr", 1600, 9999);
|
|
||||||
|
|
||||||
// Ausgabe zum Test
|
|
||||||
printf("Monat: %d, Jahr: %d \n", monat, jahr);
|
|
||||||
|
|
||||||
// Ausgabe zum Test (hier mit dem ternaeren Operator "?:")
|
|
||||||
printf("%d ist %s Schaltjahr\n", jahr, istSchaltjahr(jahr) ? "ein" : "kein");
|
|
||||||
|
|
||||||
// Ausgabe
|
|
||||||
printf("Der Monat %02d-%d hat %d Tage.\n", monat, jahr, tageProMonat(jahr, monat));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section id="aufgabe-2">
|
|
||||||
<h2>Aufgabe 2<a class="headerlink" href="#aufgabe-2" title="Permalink to this headline">¶</a></h2>
|
|
||||||
<p>Alter bestehender Boilerplate Code</p>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
||||||
<div class="sphinxsidebarwrapper">
|
|
||||||
<p class="logo">
|
|
||||||
<a href="../index.html">
|
|
||||||
<img class="logo" src="../_static/logo.png" alt="Logo"/>
|
|
||||||
|
|
||||||
<h1 class="logo logo-name">SNP Labs</h1>
|
|
||||||
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Navigation</h3>
|
|
||||||
<ul>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P01_Erste_Schritte_mit_C/README.html">01 - Erste Schritte mit C</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="README.html">02: Funktionen, Datentyp “enum”</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P03_Bit_Operation_struct_typedef/README.html">03 - Bit Operationen, Struct, Typedef</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P04_Modularisieren_von_C_Code/new_P04/P04_Modularisieren_von_C_Code.html">04 - Modularisieren von C Code</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P05_TicTacToe/README.html">05 - Arrays/Strings/TicTacToe</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P06_Personen_Verwaltung_Linked_List/README.html">06 - Personen Verwaltung – Linked List</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P07_Prozesse_und_Threads/README.html">07 - Prozesse und Threads</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P08_Sync/README.html">08 - Synchronisationsprobleme</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P09_File_Operations/README.html">09 - File Operations</a></li>
|
|
||||||
<li class="toctree-l1"><a class="reference internal" href="../P10_IPC/README.html">10 - IPC</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="relations">
|
|
||||||
<h3>Related Topics</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="../index.html">Documentation overview</a><ul>
|
|
||||||
</ul></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div id="searchbox" style="display: none" role="search">
|
|
||||||
<h3 id="searchlabel">Quick search</h3>
|
|
||||||
<div class="searchformwrapper">
|
|
||||||
<form class="search" action="../search.html" method="get">
|
|
||||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
|
||||||
<input type="submit" value="Go" />
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>$('#searchbox').show(0);</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="clearer"></div>
|
|
||||||
</div>
|
|
||||||
<div class="footer">
|
|
||||||
©2022, stsh.
|
|
||||||
|
|
||||||
|
|
|
||||||
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.4.0</a>
|
|
||||||
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
|
||||||
|
|
||||||
|
|
|
||||||
<a href="../_sources/P02_Funktionen_Datentyp_enum/README_solution.md.txt"
|
|
||||||
rel="nofollow">Page source</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||||||
|
|
||||||
|
<title>SNP - Praktika — SNP Labs documentation</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
|
||||||
|
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||||
|
<script src="_static/jquery.js"></script>
|
||||||
|
<script src="_static/underscore.js"></script>
|
||||||
|
<script src="_static/doctools.js"></script>
|
||||||
|
<link rel="index" title="Index" href="genindex.html" />
|
||||||
|
<link rel="search" title="Search" href="search.html" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
|
||||||
|
|
||||||
|
</head><body>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="document">
|
||||||
|
<div class="documentwrapper">
|
||||||
|
<div class="bodywrapper">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="body" role="main">
|
||||||
|
|
||||||
|
<section class="tex2jax_ignore mathjax_ignore" id="snp-praktika">
|
||||||
|
<h1>SNP - Praktika<a class="headerlink" href="#snp-praktika" title="Permalink to this headline">¶</a></h1>
|
||||||
|
<img align="right" title="zhaw.ch" width="176" height="92" src="en-zhaw-ines-rgb.png">
|
||||||
|
<section id="ubersicht">
|
||||||
|
<h2>Übersicht<a class="headerlink" href="#ubersicht" title="Permalink to this headline">¶</a></h2>
|
||||||
|
<p><a class="reference external" href="https://github.zhaw.ch/pages/SNP/snp-lab-code/">Online Beschreibungen der Praktika und Aufgaben</a></p>
|
||||||
|
<p><a class="reference external" href="https://github.zhaw.ch/SNP/snp-lab-code/blob/master/build/latex/main.pdf">Praktika.pdf</a></p>
|
||||||
|
<p><a class="reference external" href="https://github.zhaw.ch/SNP/snp-lab-env">Arbeitsumgebung für die Praktika</a></p>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||||
|
<div class="sphinxsidebarwrapper">
|
||||||
|
<p class="logo">
|
||||||
|
<a href="index.html">
|
||||||
|
<img class="logo" src="_static/logo.png" alt="Logo"/>
|
||||||
|
|
||||||
|
<h1 class="logo logo-name">SNP Labs</h1>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Navigation</h3>
|
||||||
|
<ul>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P01_Erste_Schritte_mit_C/README.html">01 - Erste Schritte mit C</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P02_Funktionen_Datentyp_enum/README.html">02: Funktionen, Datentyp “enum”</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P03_Bit_Operation_struct_typedef/README.html">03 - Bit Operationen, Struct, Typedef</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P04_Modularisieren_von_C_Code/new_P04/P04_Modularisieren_von_C_Code.html">04 - Modularisieren von C Code</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P05_TicTacToe/README.html">05 - Arrays/Strings/TicTacToe</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P06_Personen_Verwaltung_Linked_List/README.html">06 - Personen Verwaltung – Linked List</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P07_Prozesse_und_Threads/README.html">07 - Prozesse und Threads</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P08_Sync/README.html">08 - Synchronisationsprobleme</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P09_File_Operations/README.html">09 - File Operations</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="P10_IPC/README.html">10 - IPC</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="relations">
|
||||||
|
<h3>Related Topics</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="index.html">Documentation overview</a><ul>
|
||||||
|
</ul></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="searchbox" style="display: none" role="search">
|
||||||
|
<h3 id="searchlabel">Quick search</h3>
|
||||||
|
<div class="searchformwrapper">
|
||||||
|
<form class="search" action="search.html" method="get">
|
||||||
|
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||||
|
<input type="submit" value="Go" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>$('#searchbox').show(0);</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="clearer"></div>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
©2022, stsh.
|
||||||
|
|
||||||
|
|
|
||||||
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 4.4.0</a>
|
||||||
|
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
||||||
|
|
||||||
|
|
|
||||||
|
<a href="_sources/README.md.txt"
|
||||||
|
rel="nofollow">Page source</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -7,7 +7,7 @@ In diesem Praktikum erstellen Sie mehrere kleine C-Programme, in denen Sie Input
|
||||||
|
|
||||||
Arbeiten Sie in Zweiergruppen und diskutieren Sie ihre Lösungsansätze miteinander, bevor Sie diese umsetzen.
|
Arbeiten Sie in Zweiergruppen und diskutieren Sie ihre Lösungsansätze miteinander, bevor Sie diese umsetzen.
|
||||||
|
|
||||||
Bevor Sie mit den Programmieraufgaben beginnen, setzen Sie eine virtuelle Maschine mit der vorbereiteten Praktikumsumgebung auf.
|
Bevor Sie mit den Programmieraufgaben beginnen, setzen Sie eine virtuelle Maschine mit der vorbereiteten Praktikumsumgebung auf. Die entsprechende Anleitung finden Sie hier: [https://github.zhaw.ch/SNP/snp-lab-env/blob/master/docs/Arbeitsumgebung_f%C3%BCr_die_Praktika.pdf](https://github.zhaw.ch/SNP/snp-lab-env/blob/master/docs/Arbeitsumgebung_f%C3%BCr_die_Praktika.pdf).
|
||||||
|
|
||||||
___
|
___
|
||||||
## 2. Lernziele
|
## 2. Lernziele
|
||||||
|
|
|
@ -1,125 +0,0 @@
|
||||||
|
|
||||||
# Lösungsskizzen
|
|
||||||
## Aufgabe 1
|
|
||||||
```
|
|
||||||
/**
|
|
||||||
* Tage Pro Monat
|
|
||||||
*
|
|
||||||
* Das Programm liest einen Monat (1-12) und ein Jahr (1600-2400) ein und
|
|
||||||
* gibt die Anzahl der Tage dieses Monats aus.
|
|
||||||
*
|
|
||||||
* @author Gerrit Burkert, Adaptation bazz
|
|
||||||
* @version 15-FEB-2013, 16-OCT-2017, 17-OCT-2019, 16-FEB-2022
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define ERROR_IN_MONTH 1
|
|
||||||
#define ERROR_IN_YEAR 2
|
|
||||||
|
|
||||||
///// Student Code
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Konstante Werte fuer die Monate
|
|
||||||
// ===============================
|
|
||||||
|
|
||||||
enum { JAN=1, FEB, MAR, APR, MAI, JUN, JUL, AUG, SEP, OKT, NOV, DEZ };
|
|
||||||
|
|
||||||
|
|
||||||
// Eingabe pruefen (0 ist vom atoi als Fehelcode verwendet und darf nicht verwendet werden)
|
|
||||||
// ===============
|
|
||||||
|
|
||||||
int gibIntWert(char *name, int von, int bis) {
|
|
||||||
|
|
||||||
int wert;
|
|
||||||
char wertS[20]; //
|
|
||||||
|
|
||||||
do {
|
|
||||||
printf("%s: ", name);
|
|
||||||
fgets(wertS, 20, stdin);
|
|
||||||
wert = atoi(wertS);
|
|
||||||
if (wert < von || wert > bis) {
|
|
||||||
printf("Der Wert muss zwischen %d und %d sein.\n", von, bis);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while(1);
|
|
||||||
return wert;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Schaltjahr bestimmen
|
|
||||||
// ====================
|
|
||||||
|
|
||||||
int istSchaltjahr(int jahr){
|
|
||||||
|
|
||||||
if ( (jahr % 400 == 0) || ( (jahr %100 != 0) && (jahr % 4 ==0) ) )
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Berechnung Anzahl Tage pro Monat
|
|
||||||
// ================================
|
|
||||||
|
|
||||||
int tageProMonat(int jahr, int monat) {
|
|
||||||
|
|
||||||
int anzTage;
|
|
||||||
|
|
||||||
// Tage pro Monat bestimmen
|
|
||||||
switch (monat) {
|
|
||||||
|
|
||||||
// Monate mit 31 Tagen
|
|
||||||
case JAN: case MAR: case MAI: case JUL: case AUG: case OKT: case DEZ:
|
|
||||||
anzTage = 31;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Monate mit 30 Tagen
|
|
||||||
case APR: case JUN: case SEP: case NOV:
|
|
||||||
anzTage = 30;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Februar: 28 oder 29 Tage
|
|
||||||
case FEB:
|
|
||||||
|
|
||||||
if (istSchaltjahr(jahr)) {
|
|
||||||
anzTage = 29;
|
|
||||||
} else {
|
|
||||||
anzTage = 28;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return anzTage;
|
|
||||||
}
|
|
||||||
|
|
||||||
///// END Student Code
|
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
|
||||||
|
|
||||||
int monat, jahr;
|
|
||||||
|
|
||||||
// Monat einlesen und Bereich ueberpruefen
|
|
||||||
monat = gibIntWert("Monat", 1, 12);
|
|
||||||
jahr = gibIntWert("Jahr", 1600, 9999);
|
|
||||||
|
|
||||||
// Ausgabe zum Test
|
|
||||||
printf("Monat: %d, Jahr: %d \n", monat, jahr);
|
|
||||||
|
|
||||||
// Ausgabe zum Test (hier mit dem ternaeren Operator "?:")
|
|
||||||
printf("%d ist %s Schaltjahr\n", jahr, istSchaltjahr(jahr) ? "ein" : "kein");
|
|
||||||
|
|
||||||
// Ausgabe
|
|
||||||
printf("Der Monat %02d-%d hat %d Tage.\n", monat, jahr, tageProMonat(jahr, monat));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
## Aufgabe 2
|
|
||||||
Alter bestehender Boilerplate Code
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# SNP - Praktika
|
||||||
|
<img align="right" title="zhaw.ch" width="176" height="92" src="en-zhaw-ines-rgb.png">
|
||||||
|
|
||||||
|
|
||||||
|
### Übersicht
|
||||||
|
[Online Beschreibungen der Praktika und Aufgaben](https://github.zhaw.ch/pages/SNP/snp-lab-code/)
|
||||||
|
|
||||||
|
[Praktika.pdf](https://github.zhaw.ch/SNP/snp-lab-code/blob/master/build/latex/main.pdf)
|
||||||
|
|
||||||
|
[Arbeitsumgebung für die Praktika](https://github.zhaw.ch/SNP/snp-lab-env)
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue