|
@@ -0,0 +1,573 @@
|
|
|
+\documentclass[10pt]{beamer}
|
|
|
+\setbeamercovered{transparent}
|
|
|
+\usetheme{Antibes}
|
|
|
+\usecolortheme{beaver}
|
|
|
+\usepackage[utf8]{inputenc}
|
|
|
+\usepackage[svgpath=images/]{svg}
|
|
|
+\usepackage{graphicx}
|
|
|
+\graphicspath{ {images/} }
|
|
|
+\usepackage[hyphenbreaks]{breakurl}
|
|
|
+\usepackage{hyperref}
|
|
|
+\hypersetup{breaklinks=true}
|
|
|
+\usepackage{subcaption}
|
|
|
+\usepackage{makecell}
|
|
|
+\usepackage{dirtytalk}
|
|
|
+\usepackage{amsmath}
|
|
|
+\usepackage{mathtools}
|
|
|
+\usepackage{listingsutf8}
|
|
|
+\usepackage[italian]{babel}
|
|
|
+
|
|
|
+% Todo red marker
|
|
|
+\usepackage{xcolor}
|
|
|
+\newcommand{\todo}[1]{}
|
|
|
+\renewcommand{\todo}[1]{{\color{red} TODO: {#1}}}
|
|
|
+
|
|
|
+% Stuff for presentation
|
|
|
+\usepackage{pgfpages}
|
|
|
+\setbeameroption{hide notes} % Only slides
|
|
|
+%\setbeameroption{show only notes} % Only notes
|
|
|
+%\setbeameroption{show notes}
|
|
|
+%\setbeameroption{show notes on second screen=right} % Both
|
|
|
+
|
|
|
+% Give a slight yellow tint to the notes page
|
|
|
+%\setbeamertemplate{note page}{\pagecolor{yellow!5}\insertnote}\usepackage{palatino}
|
|
|
+
|
|
|
+% Remove beamer navigation stuff
|
|
|
+%\setbeamertemplate{navigation symbols}{}
|
|
|
+
|
|
|
+\beamertemplatenavigationsymbolsempty
|
|
|
+
|
|
|
+%\setbeamerfont{page number in head/foot}{size=\small}
|
|
|
+%\setbeamertemplate{page number in head/foot}[framenumber]
|
|
|
+%\setbeamertemplate{page number in head/foot}[totalframenumber]
|
|
|
+\setbeamertemplate{footline}[frame number]
|
|
|
+
|
|
|
+% Listings packages
|
|
|
+\usepackage{verbatim}
|
|
|
+\usepackage{inconsolata}
|
|
|
+\usepackage{listings}
|
|
|
+\usepackage{multicol}
|
|
|
+\usepackage{lscape}
|
|
|
+\newcommand{\optcolor}[1]{\color{#1}}
|
|
|
+\lstset{
|
|
|
+ basicstyle={\ttfamily\footnotesize},
|
|
|
+ keywordstyle=\optcolor{blue},
|
|
|
+ stringstyle=\optcolor{red},
|
|
|
+ %commentstyle=\optcolor{green},
|
|
|
+ morecomment=[l][\optcolor{magenta}]{\#},
|
|
|
+ escapechar={|},
|
|
|
+}
|
|
|
+
|
|
|
+\definecolor{alt}{gray}{0.9}
|
|
|
+\definecolor{darkgreen}{rgb}{0,0.65,0}
|
|
|
+\lstdefinelanguage{llvm}{
|
|
|
+ basicstyle={\ttfamily\footnotesize},
|
|
|
+ morecomment = [l]{;},
|
|
|
+ commentstyle=\optcolor{darkgreen},
|
|
|
+ morestring=[b]",
|
|
|
+ sensitive = true,
|
|
|
+ classoffset=0,
|
|
|
+ alsoletter=:\%.,
|
|
|
+ keywordstyle=\optcolor{teal},
|
|
|
+ keywordsprefix={\%},
|
|
|
+ morekeywords={\@a},
|
|
|
+ %keywordstyle=\optcolor{darkgray},
|
|
|
+ classoffset=1,
|
|
|
+ keywordstyle=\optcolor{blue},
|
|
|
+ morekeywords={
|
|
|
+ define, declare, global, constant,
|
|
|
+ internal, external, private,
|
|
|
+ linkonce, linkonce_odr, weak, weak_odr, appending,
|
|
|
+ common, extern_weak,
|
|
|
+ thread_local, dllimport, dllexport,
|
|
|
+ hidden, protected, default,
|
|
|
+ except, deplibs,
|
|
|
+ volatile, fastcc, coldcc, cc, ccc,
|
|
|
+ x86_stdcallcc, x86_fastcallcc,
|
|
|
+ ptx_kernel, ptx_device,
|
|
|
+ signext, zeroext, inreg, sret, nounwind, noreturn,
|
|
|
+ nocapture, byval, nest, readnone, readonly, noalias, uwtable,
|
|
|
+ inlinehint, noinline, alwaysinline, optsize, ssp, sspreq,
|
|
|
+ noredzone, noimplicitfloat, naked, alignstack,
|
|
|
+ module, asm, align, tail, to,
|
|
|
+ addrspace, section, alias, sideeffect, c, gc,
|
|
|
+ target, datalayout, triple,
|
|
|
+ blockaddress
|
|
|
+ },
|
|
|
+ classoffset=2,keywordstyle=\optcolor{blue},
|
|
|
+ morekeywords={
|
|
|
+ fadd, sub, fsub, mul, fmul, add,
|
|
|
+ sdiv, udiv, fdiv, srem, urem, frem,
|
|
|
+ and, or, xor,
|
|
|
+ icmp, fcmp,
|
|
|
+ eq, ne, ugt, uge, ult, ule, sgt, sge, slt, sle,
|
|
|
+ oeq, ogt, oge, olt, ole, ord, ueq, ugt, uge,
|
|
|
+ ult, ule, une, uno,
|
|
|
+ nuw, nsw, exact, inbounds,
|
|
|
+ phi, call, select, shl, lshr, ashr, va_arg,
|
|
|
+ trunc, zext, sext,
|
|
|
+ fptrunc, fpext, fptoui, fptosi, uitofp, sitofp,
|
|
|
+ ptrtoint, inttoptr, bitcast,
|
|
|
+ ret, br, indirectbr, switch, invoke, unwind, unreachable,
|
|
|
+ malloc, alloca, free, load, store, getelementptr,
|
|
|
+ extractelement, insertelement, shufflevector,
|
|
|
+ extractvalue, insertvalue,
|
|
|
+ },
|
|
|
+ classoffset=3,
|
|
|
+ keywordstyle=\optcolor{purple},
|
|
|
+ morekeywords={
|
|
|
+ @v0, @a0, @t0, @ra, @pc, @r1, @ZF, @rax,@rsp
|
|
|
+ @main,@function,@root,@function_call
|
|
|
+ },
|
|
|
+ classoffset=4,keywordstyle=\optcolor{blue},
|
|
|
+ morekeywords={
|
|
|
+i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18,
|
|
|
+i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31, i32, i33, i34,
|
|
|
+i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50,
|
|
|
+i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62, i63, i64, i80, i512,
|
|
|
+void, half, float, double, fp128, x86_fp80, ppc_fp128, x86_mmx, label, metadata
|
|
|
+ },
|
|
|
+ classoffset=5,keywordstyle=\optcolor{teal},
|
|
|
+ morekeywords={
|
|
|
+ entry:,true:,epilogue:,bb.main:,bb._init.0x8,
|
|
|
+ dispatcher:,bb.one:,bb.two:,fallthrough:,call:,BB1:,BB2:,BB3:
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+% Packages for graphs
|
|
|
+\usepackage{tikz}
|
|
|
+\usetikzlibrary{arrows,automata}
|
|
|
+\usetikzlibrary{shapes.geometric}
|
|
|
+\usetikzlibrary{positioning}
|
|
|
+\usetikzlibrary{shapes.multipart}
|
|
|
+\usetikzlibrary{positioning}
|
|
|
+\usetikzlibrary{decorations.pathreplacing}
|
|
|
+\usetikzlibrary{fit}
|
|
|
+\usetikzlibrary{calc}
|
|
|
+\usetikzlibrary{matrix}
|
|
|
+\usetikzlibrary{patterns}
|
|
|
+\usetikzlibrary{quotes}
|
|
|
+\usetikzlibrary{shapes.misc}
|
|
|
+\tikzset{
|
|
|
+ diagonal fill/.style 2 args={fill=#2, path picture={
|
|
|
+ \fill[#1, sharp corners] (path picture bounding box.south west) -|
|
|
|
+ (path picture bounding box.north east) -- cycle;}},
|
|
|
+ reversed diagonal fill/.style 2 args={fill=#2, path picture={
|
|
|
+ \fill[#1, sharp corners] (path picture bounding box.north west) |-
|
|
|
+ (path picture bounding box.south east) -- cycle;}}
|
|
|
+ }
|
|
|
+\tikzset{
|
|
|
+ fadered/.style={
|
|
|
+ very thick,
|
|
|
+ draw=red!50!black!50,
|
|
|
+ top color=white,
|
|
|
+ rounded corners=.5mm,
|
|
|
+ bottom color=red!50!black!20, % and something else at the bottom
|
|
|
+ font=\sf,
|
|
|
+ text=black
|
|
|
+ },
|
|
|
+ faderedprime/.style={
|
|
|
+ very thick,
|
|
|
+ draw=blue!50!black!50,
|
|
|
+ top color=white,
|
|
|
+ rounded corners=.5mm,
|
|
|
+ bottom color=blue!50!black!20, % and something else at the bottom
|
|
|
+ font=\sf,
|
|
|
+ text=black
|
|
|
+ },
|
|
|
+ nonterminal/.style={
|
|
|
+ fadegray,
|
|
|
+ rectangle,
|
|
|
+ minimum size=6mm,
|
|
|
+ minimum width=20mm,
|
|
|
+ minimum height=7mm,
|
|
|
+ rounded corners=3mm
|
|
|
+ },
|
|
|
+ fadegray/.style={
|
|
|
+ text=black,
|
|
|
+ very thick,draw=black!50,
|
|
|
+ top color=white,
|
|
|
+ bottom color=black!20,
|
|
|
+ font=\sf
|
|
|
+ },
|
|
|
+ terminal/.style={
|
|
|
+ rectangle,
|
|
|
+ fadered,
|
|
|
+ minimum height=7mm,
|
|
|
+ minimum width=20mm,
|
|
|
+ rounded corners=3mm,
|
|
|
+ },
|
|
|
+ terminalprime/.style={
|
|
|
+ rectangle,
|
|
|
+ faderedprime,
|
|
|
+ minimum height=7mm,
|
|
|
+ minimum width=20mm,
|
|
|
+ rounded corners=3mm,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+% Visibility on slides
|
|
|
+%\usetikzlibrary{backgrounds}
|
|
|
+%\usetikzlibrary{arrows.meta,calc,shapes.callouts,shadows.blur,positioning}
|
|
|
+%% Conditional elements in TikZ drawings
|
|
|
+\tikzset{
|
|
|
+ invisible/.style={opacity=0,text opacity=0},
|
|
|
+ visible on/.style={alt=#1{}{invisible}},
|
|
|
+ alt/.code args={<#1>#2#3}{%
|
|
|
+ \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+\def\UrlBreaks{\do\/\do-}
|
|
|
+
|
|
|
+% Pgfplots imports
|
|
|
+\usepackage{pgfplots}
|
|
|
+\usepackage{pgfplotstable}
|
|
|
+\pgfplotsset{compat=1.13}
|
|
|
+
|
|
|
+% use acm colors
|
|
|
+\definecolor[named]{ACMBlue}{cmyk}{1,0.1,0,0.1}
|
|
|
+\definecolor[named]{ACMYellow}{cmyk}{0,0.16,1,0}
|
|
|
+\definecolor[named]{ACMOrange}{cmyk}{0,0.42,1,0.01}
|
|
|
+\definecolor[named]{ACMRed}{cmyk}{0,0.90,0.86,0}
|
|
|
+\definecolor[named]{ACMLightBlue}{cmyk}{0.49,0.01,0,0}
|
|
|
+\definecolor[named]{ACMGreen}{cmyk}{0.20,0,1,0.19}
|
|
|
+\definecolor[named]{ACMPurple}{cmyk}{0.55,1,0,0.15}
|
|
|
+\definecolor[named]{ACMDarkBlue}{cmyk}{1,0.58,0,0.21}
|
|
|
+
|
|
|
+% metropolis colors
|
|
|
+\definecolor{mDarkBrown}{HTML}{604c38}
|
|
|
+\definecolor{mDarkTeal}{HTML}{23373b}
|
|
|
+\definecolor{mLightBrown}{HTML}{EB811B}
|
|
|
+\definecolor{mLightGreen}{HTML}{14B03D}
|
|
|
+
|
|
|
+% Custom commands
|
|
|
+\newcommand{\ccode}[1]{\texttt{#1}}
|
|
|
+\usepackage{xspace}
|
|
|
+\newcommand{\newcommandx}[2]{\newcommand{#1}{#2\xspace}}
|
|
|
+\newcommandx{\revng}{\texttt{rev.ng}}
|
|
|
+\newcommandx{\llvm}{\textsc{llvm}}
|
|
|
+\newcommandx{\llvmcapi}{\textsc{llvm-c API}}
|
|
|
+\newcommandx{\llvmir}{\textsc{llvm ir}}
|
|
|
+\newcommandx{\qemuir}{\textsc{qemu ir}}
|
|
|
+\newcommandx{\qemu}{\textsc{qemu}}
|
|
|
+\newcommandx{\gcc}{\texttt{gcc}}
|
|
|
+\newcommand{\revamb}{\texttt{revamb}}
|
|
|
+\newcommand{\llvmcpy}{\texttt{llvmcpy}}
|
|
|
+
|
|
|
+\usepackage[noframe]{showframe}
|
|
|
+\usepackage{biblatex}[
|
|
|
+ backend=biber,
|
|
|
+ style=numeric,
|
|
|
+]
|
|
|
+
|
|
|
+% Python stuff
|
|
|
+% Default fixed font does not support bold face
|
|
|
+\DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{10} % for bold
|
|
|
+\DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{10} % for normal
|
|
|
+
|
|
|
+% Custom colors
|
|
|
+\usepackage{color}
|
|
|
+\definecolor{deepblue}{rgb}{0,0,0.5}
|
|
|
+\definecolor{deepred}{rgb}{0.6,0,0}
|
|
|
+\definecolor{deepgreen}{rgb}{0,0.5,0}
|
|
|
+
|
|
|
+\usepackage{listings}
|
|
|
+
|
|
|
+% Python style for highlighting
|
|
|
+\newcommand\pythonstyle{\lstset{
|
|
|
+ language=Python,
|
|
|
+ basicstyle=\ttm,
|
|
|
+ otherkeywords={self}, % Add keywords here
|
|
|
+ keywordstyle=\ttb\color{deepblue},
|
|
|
+ emph={MyClass,__init__}, % Custom highlighting
|
|
|
+ emphstyle=\ttb\color{deepred}, % Custom highlighting style
|
|
|
+ stringstyle=\color{deepgreen},
|
|
|
+ frame=tb, % Any extra options here
|
|
|
+ showstringspaces=false %
|
|
|
+}}
|
|
|
+
|
|
|
+% Python environment
|
|
|
+\lstnewenvironment{python}[1][]
|
|
|
+{
|
|
|
+ \pythonstyle
|
|
|
+ \lstset{#1}
|
|
|
+}
|
|
|
+{}
|
|
|
+
|
|
|
+% Python for external files
|
|
|
+\newcommand\pythonexternal[2][]{{
|
|
|
+ \pythonstyle
|
|
|
+\lstinputlisting[#1]{#2}}}
|
|
|
+\lstset{inputencoding=utf8/latin1}
|
|
|
+
|
|
|
+% Python for inline
|
|
|
+\newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}
|
|
|
+
|
|
|
+% C environment
|
|
|
+
|
|
|
+\definecolor{mGreen}{rgb}{0,0.6,0}
|
|
|
+\definecolor{mGray}{rgb}{0.5,0.5,0.5}
|
|
|
+\definecolor{mPurple}{rgb}{0.58,0,0.82}
|
|
|
+\definecolor{backgroundColour}{rgb}{0.95,0.95,0.92}
|
|
|
+
|
|
|
+\lstdefinestyle{CStyle}{
|
|
|
+ backgroundcolor=\color{backgroundColour},
|
|
|
+ commentstyle=\color{mGreen},
|
|
|
+ keywordstyle=\color{magenta},
|
|
|
+ numberstyle=\tiny\color{mGray},
|
|
|
+ stringstyle=\color{mPurple},
|
|
|
+ basicstyle=\footnotesize,
|
|
|
+ breakatwhitespace=false,
|
|
|
+ breaklines=true,
|
|
|
+ captionpos=b,
|
|
|
+ keepspaces=true,
|
|
|
+ numbers=left,
|
|
|
+ numbersep=5pt,
|
|
|
+ showspaces=false,
|
|
|
+ showstringspaces=false,
|
|
|
+ showtabs=false,
|
|
|
+ tabsize=2,
|
|
|
+ language=C
|
|
|
+}
|
|
|
+\lstnewenvironment{C}[1][]
|
|
|
+{
|
|
|
+ \lstset{style=CStyle}
|
|
|
+}
|
|
|
+{}
|
|
|
+
|
|
|
+%\addbibresource{bibliography.bib}
|
|
|
+
|
|
|
+%\setbeamersize{text margin left=15pt,text margin right=15pt}
|
|
|
+
|
|
|
+% Information to be included in the title page:
|
|
|
+\title[]{Fondamenti di Informatica}
|
|
|
+%\subtitle{Presentation relative to ACACES 2019}
|
|
|
+\author{Andrea Gussoni\\andrea1.gussoni at polimi.it}
|
|
|
+\institute{Politecnico di Milano}
|
|
|
+\date{May 25, 2021}
|
|
|
+%\titlegraphic{\includegraphics[width=0.60\textwidth]{logo-polimi}}
|
|
|
+
|
|
|
+% Create section header slide
|
|
|
+\AtBeginSection{\frame{\sectionpage}}
|
|
|
+\begin{document}
|
|
|
+
|
|
|
+\frame{\titlepage
|
|
|
+ \note[item]{My name is ...}
|
|
|
+ \note[item]{Thank the audience.}}
|
|
|
+
|
|
|
+\begin{frame}
|
|
|
+ \frametitle{Table of Contents}
|
|
|
+ \tableofcontents
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\section{Ripasso Esercitazione Precedente}
|
|
|
+\begin{frame}{Ripasso}
|
|
|
+ \begin{alertblock}{}
|
|
|
+ Problemi con esercizi della precedente esercitazione?
|
|
|
+ \end{alertblock}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{\ccode{wc}}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Nei sistemi Unix e derivati, il comando \ccode{wc} fornisce il numeri di caratteri, numero di parole, e numero di linee contenute in un file di testo.
|
|
|
+ \item Implementare in linguaggio C una funzione che prende in input il nome di un file e ne restituisce le statistiche del comando \ccode{wc}.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Cifrario di Cesare}
|
|
|
+ \begin{itemize}
|
|
|
+ \item In antichità, il cifrario di Cesare è stato uno dei più antichi algoritmi crittografici conosciuti, usato da Giulio Cesare per cifrare messaggi.
|
|
|
+ \item Funziona tramite uno shift di 3 caratteri, per ogni lettera del messaggio originale. Ad esempio, la parola "CANE", diventa "FDQH".
|
|
|
+ \item Per decifrare il messaggio, si può effettuare la procedura inversa ovviamente.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Movimenti Bancari}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Un file contenente le informazioni sui movimenti di un conto corrente bancario (in Euro) ha il seguente formato.
|
|
|
+ \item La prima riga contiene una stringa con l’IBAN del conto corrente.
|
|
|
+ \item La seconda riga contiene il saldo iniziale (sempre positivo).
|
|
|
+ \item Le righe seguenti formano una sequenza di movimenti.
|
|
|
+ \item Ogni movimento è descritto dalla data del movimento nel formato aaaa-mm-gg, l’importo del movimento espresso in Euro (da rappresentare con un numero \ccode{float}, dato che può contenere cifre decimali) e un carattere che può essere il segno + (entrata) oppure - (uscita). Ciascun movimento è posto su di una singola riga del file, con un carattere di spazio, usato come separatore dei valori sulla riga. I movimenti sono riportati nel file in ordine cronologico crescente: non esistono due movimenti effettuati nel medesimo giorno.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Movimenti Bancari}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Scrivere la funzione:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+void dataLimite(char nomefile[],
|
|
|
+ float limCredito,
|
|
|
+ char *dataRestituita);
|
|
|
+ \end{lstlisting}
|
|
|
+ \item che prende come parametri il nome di un file contenente le informazioni di un conto corrente nel formato sopra descritto e un limite di credito $limCredito$ (con $limCredito < 0$), e restituisce tramite l'uso del terzo parametro $char *dataRestituita$ la data in cui il saldo è sceso sotto il valore limite passato come parametro.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Movimenti Bancari}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Dato il tipo di dato seguente:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+typedef struct mov {
|
|
|
+ char data[10+1];
|
|
|
+ float importo;
|
|
|
+ char segno;
|
|
|
+} t_movimento;
|
|
|
+ \end{lstlisting}
|
|
|
+ \item scrivere in C la funzione:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+void leggiEstratto(char nomefile[],
|
|
|
+ t_movimento *movimenti,
|
|
|
+ int *lung,
|
|
|
+ int *saldoIniziale)
|
|
|
+ \end{lstlisting}
|
|
|
+che prende come parametri il nome di un file contenente le informazioni di un conto corrente nel formato descritto nel precedente esercizio e un puntatore ad un array in cui inseriremo tutti i movimenti presenti all’interno del file.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Movimenti Bancari}
|
|
|
+ \begin{itemize}
|
|
|
+ \item L’array avrà quindi tante celle di tipo \ccode{t\_movimento} quante sono le righe del file che descrivono un movimento. Il secondo e il terzo parametro sono da intendersi come parametri passati per indirizzo per restituire al chiamante la lunghezza del vettore e il saldo iniziale del conto corrente.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Movimenti Bancari}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Si considerino le ulteriori definizioni di tipo di dato:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+typedef struct t_entrateUscite{
|
|
|
+ float totEntrate;
|
|
|
+ float totUscite;
|
|
|
+} t_bilancio;
|
|
|
+typedef t_bilancio bilancioMensile[12];
|
|
|
+ \end{lstlisting}
|
|
|
+ \item Scrivere in C il sottoprogramma:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+void calcolaBilanciMensili(t_movimento *elenco,
|
|
|
+ int lung,
|
|
|
+ int anno,
|
|
|
+ t_bilancio ris[12]);
|
|
|
+ \end{lstlisting}
|
|
|
+che prende come parametri un array contenente l’elenco dei movimenti di un conto corrente, la lunghezza dell’array e un valore intero indicante un anno (per esempio: 2019).
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Movimenti Bancari}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Il sottoprogramma riempie l’array passato come quarto parametro memorizzando nella 1ma cella i totali delle entrate e delle uscite relative al mese di Gennaio, nella seconda cella i totali delle entrate e delle uscite relative al mese di Febbraio ecc.
|
|
|
+ \item Nota: potrebbe essere utile definire e usare due sottoprogrammi:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+int numAnno(char data[]); int numMese(char data[]);
|
|
|
+ \end{lstlisting}
|
|
|
+per ottenere dalla stringa con formato aaaa-mm-gg, passata come parametro, un numero con il valore dell’anno e un numero con il valore del mese, rispettivamente. Si assuma 1=Gennaio, 2=Febbraio, ecc.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Prodotto interno lordo}
|
|
|
+ \begin{itemize}
|
|
|
+ \item il prodotto interno lordo (pil) è una delle grandezze macro-economiche fondamentali e rappresenta il valore
|
|
|
+ di mercato di tutti i beni e servizi finali prodotti in una nazione, in un dato periodo di tempo.
|
|
|
+ per esempio, la farina è un “bene finale” se venduta come farina; un “bene intermedio” se venduta al panettiere
|
|
|
+ per fare il pane; in questo caso il valore della farina è incorporato nel valore del pane.
|
|
|
+ \item limitandosi a considerare solo beni di consumo (trascurando quindi i beni e i servizi di investimento), si
|
|
|
+ considerino due file di testo, chiamati rispettivamente \ccode{benifinali.txt} e \ccode{materiali.txt}.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Prodotto interno lordo}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Il file BeniFinali.txt include un elenco di righi, dove ciascun rigo riporta una stringa alfanumerica (univoca)
|
|
|
+ di dieci caratteri per identificare un bene (ID\_bene), una stringa senza spazi all’interno e lunga al massimo
|
|
|
+ cinquanta caratteri contentente il nome del bene (nome), e un prezzo di vendita unitario espresso in euro
|
|
|
+ (prezzo\_unitario), separati da un carattere di spazio.
|
|
|
+ \item Il file Materiali.txt include un elenco di righi, dove ciascun rigo riporta una stringa alfanumerica lunga
|
|
|
+ dieci caratteri per identificare un bene finale, una stringa alfanumerica lunga dieci caratteri per identificare un
|
|
|
+ bene intermedio e la quantità necessaria di prodotto intermedio (indicata come un numero frazionario), per la
|
|
|
+ produzione del primo prodotto.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Prodotto interno lordo}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Dichiarare in C due tipi di dato, chiamati bene\_finale\_t e materiale\_t, per rappresentare in memoria
|
|
|
+ ciascun un rigo del primo e del secondo file, rispettivamente.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Prodotto interno lordo}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Si consideri la seguente definizione di tipo di dato:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+typedef struct {
|
|
|
+ bene_finale_t b;
|
|
|
+ float quantita;
|
|
|
+} vendita_t;
|
|
|
+ \end{lstlisting}
|
|
|
+\item Scrivere in C il codice della funzione int main(){...} che apra il file BeniFinali.txt, conteggi il
|
|
|
+numero complessivo di beni di consumo da considerare per il calcolo del PIL (cioè calcoli il numero di righi nel
|
|
|
+file) e dichiarando un vettore di tipo vendita\_t di una lunghezza massima prefissata (superiore sicuramente al numero di beni
|
|
|
+descritti nel file BeniFinali.txt), lo inizializzi acquisendo da tastiera la quantità di prodotto venduta per
|
|
|
+ciascun bene.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Prodotto interno lordo}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Scrivere in C la funzione:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+float calcola_valore_aggiunto(char ID[],
|
|
|
+ char nomeFileMateriali[],
|
|
|
+ vendita_t elenco[],
|
|
|
+ int lungElenco);
|
|
|
+ \end{lstlisting}
|
|
|
+avente come argomenti l'identificativo di un bene, una stringa contenente il nome del file con le informazioni
|
|
|
+sui materiali necessari per produrlo (quindi un file di testo organizzato come Materiali.txt), un array di
|
|
|
+tipo vendita\_t e la lunghezza di quest'ultimo.
|
|
|
+ \item La funzione restituisce un numero frazionario calcolato come la differenza tra il prezzo di vendita del bene (con
|
|
|
+identificativo passato come parametro) meno i prezzi delle quantità di materiale impiegate per produrlo.
|
|
|
+La funzione restituisce il valore 0.0 nel caso in cui l'identificativo passato come parametro non corrisponda ad
|
|
|
+alcun bene.
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{frame}[fragile]{Prodotto interno lordo}
|
|
|
+ \begin{itemize}
|
|
|
+ \item Scrivere in C la funzione:
|
|
|
+ \begin{lstlisting}[language=C]
|
|
|
+...calcola_PIL_consumi(...)
|
|
|
+ \end{lstlisting}
|
|
|
+avente come parametri un array di tipo vendita\_t e la sua lunghezza, e che restituisca il PIL dei consumi,
|
|
|
+calcolato come la somma dei “valori aggiunti” dei beni presenti nell'array passato come parametro e tenendo
|
|
|
+conto delle quantità dei beni in esso riportate.
|
|
|
+
|
|
|
+ \end{itemize}
|
|
|
+\end{frame}
|
|
|
+
|
|
|
+\begin{comment}
|
|
|
+\section{Extra}
|
|
|
+\begin{frame}[fragile]{Monte Carlo}
|
|
|
+ Scrivere un programma che calcoli il valore di $\pi$, utilizzando il metodo di Monte Carlo.
|
|
|
+\end{frame}
|
|
|
+\end{comment}
|
|
|
+
|
|
|
+\begin{comment}
|
|
|
+\begin{frame}[t,allowframebreaks]
|
|
|
+ \frametitle{References}
|
|
|
+ \nocite{*}
|
|
|
+ \printbibliography
|
|
|
+\end{frame}
|
|
|
+\end{comment}
|
|
|
+
|
|
|
+\begin{comment}
|
|
|
+\begin{frame}
|
|
|
+ \frametitle{License}
|
|
|
+ \begin{center}
|
|
|
+ \vfill
|
|
|
+ \includesvg[height=1.5cm]{by-sa}\\
|
|
|
+ {\footnotesize These slides are published under a Creative Commons Attribution-ShareAlike 4.0 license\footnote{\url{https://creativecommons.org/licenses/by-sa/4.0/}}.}
|
|
|
+ \end{center}
|
|
|
+\end{frame}
|
|
|
+\end{comment}
|
|
|
+
|
|
|
+\end{document}
|