c-first-steps

a C playground
Index Commits Files Refs README
commit bacdc0f7c7d45928651052a1661d4eaf30a6ccd2
parent ad9df424694f43f76e1607c0f8c0a23b79d8cf87
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Sat, 14 Nov 2020 12:42:35 -0300

Updated: reorganized directories

Diffstat:
Dsrc/guia02/ej1.c | 16----------------
Dsrc/guia02/ej2.c | 21---------------------
Dsrc/guia02/ej3.c | 15---------------
Dsrc/guia02/ej4.c | 79-------------------------------------------------------------------------------
Dsrc/guia02/ej5.c | 62--------------------------------------------------------------
Dsrc/guia02/ej6.c | 27---------------------------
Dsrc/guia02/ej7.c | 62--------------------------------------------------------------
Dsrc/guia02/ej7_2.c | 42------------------------------------------
Dsrc/guia02/ej8.c | 73-------------------------------------------------------------------------
Dsrc/guia02/guia02.pdf | 0
10 files changed, 0 insertions(+), 397 deletions(-)
diff --git a/src/guia02/ej1.c b/src/guia02/ej1.c
@@ -1,16 +0,0 @@
-#include <stdio.h>
-
-typedef enum {
-        FALSE,
-        TRUE
-} bool_t; 
-
-int main(void)
-{
-    bool_t isworking = TRUE;
-    printf("%s\n", isworking ? "TRUE" : "FALSE");
-
-    return 0;
-}
-
-
diff --git a/src/guia02/ej2.c b/src/guia02/ej2.c
@@ -1,21 +0,0 @@
-#include <stdio.h>
-
-typedef enum {
-        ERROR,
-        OK
-} status_t; 
-
-int main(void)
-{
-
-    status_t isworking = OK;
-
-    if (isworking == 1)
-        printf("OK\n");
-    else
-        printf("ERROR\n");
-
-    return 0;
-}
-
-
diff --git a/src/guia02/ej3.c b/src/guia02/ej3.c
@@ -1,15 +0,0 @@
-#include <stdio.h>
-
-typedef enum {
-    LUN, MAR, MIE, JUE, VIE, SAB, DOM
-} dia_t;
-
-int main(void)
-{
-    dia_t dia = VIE;
-
-    printf("%d\n", dia);
-    
-
-    return 0;
-}
diff --git a/src/guia02/ej4.c b/src/guia02/ej4.c
@@ -1,79 +0,0 @@
-/*    Ejercicio 4 - Guia 2, Algoritmos y Programacion I - FIUBA    */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define MAX_INP_LEN 10
-
-typedef enum {
-    FAHRENHEIT,
-    CELSIUS
-} escala_t;
-
-typedef float dato_t;    
-                    
-dato_t ftoc(dato_t fahrenheit)
-{
-    return (((fahrenheit - 32) *5 ) / 9);
-}
-
-dato_t ctof(dato_t celsius)
-{
-    return (((celsius * 9) / 5) + 32);
-}
-
-void title(int i)
-{
-    printf(
-        "---------------------------------------\n"
-        "---------------------------------------\n"
-        "--- %s TO %s CONVERTER ---\n"
-        "---------------------------------------\n"
-        "---      to exit press Ctrl+D      ----\n"
-        "---------------------------------------\n"
-        "---------------------------------------\n",
-        i ? "CELSIUS" : "FAHRENHEIT",
-        i ? "FAHRENHEIT" : "CELSIUS"
-    );
-}
-
-void cursor()
-{
-    printf(">> ");
-}
-
-
-
-int main(void)
-{
-    char buffer[MAX_INP_LEN];
-    escala_t c;
-    dato_t i, res;
-    printf("0 - FAHRENHEIT TO CELSIUS\n");
-    printf("1 - CELSIUS TO FAHRENHEIT\n");
-    cursor();
-    c = getchar() - '0';
-    if (c == FAHRENHEIT) {
-        title(FAHRENHEIT);
-        while (fgets(buffer, MAX_INP_LEN, stdin) != NULL) {
-            i = atoi(buffer);
-            res = ftoc(i);
-            printf("%.0f°F = %.2f°C\n", i, res);
-            cursor();
-        }
-    } else if (c == CELSIUS) {
-        title(CELSIUS);
-        while (fgets(buffer, MAX_INP_LEN, stdin) != NULL) {
-            i = atoi(buffer);
-            res = ctof(i);
-            printf("%.0f°C = %.2f°F\n", i, res);
-            cursor();
-        }
-    }
-    printf("\n");
-    return 0;
-}
-
-
-
diff --git a/src/guia02/ej5.c b/src/guia02/ej5.c
@@ -1,62 +0,0 @@
-#include <stdio.h>
-
-typedef enum {
-    JAN, FEB, MAR, APR, MAY, JUN, JUL, AGO, SEP, OCT, NOV, DEC
-} mes_t;
-
-#define JANUARY        "ENERO\n"
-#define FEBRUARY    "FEBRERO\n"
-#define MARCH         "MARZO\n"
-#define APRIL        "ABRIL\n"
-#define MAYO        "MAYO\n"
-#define JUNE        "JUNIO\n"
-#define JULY        "JULIO\n"
-#define AUGUST        "AGOSTO\n"
-#define SEPTEMBER    "SEPTIEMBRE\n"
-#define OCTOBER        "OCTUBRE\n"
-#define NOVEMBER    "NOVIEMBRE\n"
-#define DECEMBER    "DICIEMBRE\n"
-
-int main(void) {
-    mes_t mes = NOV;
-    switch(mes)
-    {
-        case JAN:
-            printf(JANUARY);
-            break;
-        case FEB:
-            printf(FEBRUARY);
-            break;
-        case MAR:
-            printf(MARCH);
-            break;
-        case APR:
-            printf(APRIL);
-            break;
-        case MAY:
-            printf(MAYO);
-            break;
-        case JUN:
-            printf(JUNE);
-            break;
-        case JUL:
-            printf(JULY);
-            break;
-        case AGO:
-            printf(AUGUST);
-            break;
-        case SEP:
-            printf(SEPTEMBER);
-            break;
-        case OCT:
-            printf(OCTOBER);
-            break;
-        case NOV:
-            printf(NOVEMBER);
-            break;
-        case DEC:
-            printf(DECEMBER);
-            break;
-    }    
-    return 0;
-}
diff --git a/src/guia02/ej6.c b/src/guia02/ej6.c
@@ -1,27 +0,0 @@
-#include <stdio.h>
-#include <ctype.h>
-
-int main(void)
-{
-    int alpha, nonalpha, num;
-    int c;
-    
-    alpha = nonalpha = num = 0;
-
-    while((c = getchar()) != EOF ) {
-        if(isalpha(c))
-            alpha++;
-        else if(isdigit(c))
-            num++;
-        else if(!isalnum(c))
-            nonalpha++;
-    }
-    printf(
-        "Alphanumerics: %d\n"
-        "NonAlphanumerics: %d\n"
-        "Digits: %d\n",
-        alpha, nonalpha, num
-    );
-
-    return 0;
-}
diff --git a/src/guia02/ej7.c b/src/guia02/ej7.c
@@ -1,62 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#define MAX_LEN 5    // max digits of the entered degree;
-#define ERR_MSG_LEN "El angulo ingresado contiene demasiados digitos"
-
-typedef enum {
-    AGUDO, OBTUSO, RECTO
-} angulo_t;
-
-
-void clean(char *buffer)
-{
-    for(size_t i = 0; i < MAX_LEN; i++)
-        buffer[i] = '\0';
-}
-
-
-int main(void) {
-    
-    char buffer[MAX_LEN];
-    clean(buffer);
-    int c, d, e, i;
-    i = 0;        
-    while(((c = getchar()) != EOF) && c != '\n') {
-        if(i < MAX_LEN) {
-            buffer[i] = c;
-            i++;
-        } else if (i >= MAX_LEN) {
-            fprintf(stderr, ERR_MSG_LEN"\n");
-            return 1;
-        }
-    }
-    d = atoi(buffer);
-
-    if (d < 90)
-        e = AGUDO;
-    else if (d == 90)
-        e = RECTO;
-    else if (d > 90)
-        e = OBTUSO;
-
-
-    switch (e)
-    {
-        case AGUDO:
-            printf("El angulo es AGUDO\n");
-            break;
-        case RECTO:
-            printf("El angulo es RECTO\n");
-            break;
-        case OBTUSO:
-            printf("El angulo es OBTUSO\n");
-            break;
-    }
-    return 0;
-}
-
-
-
-
diff --git a/src/guia02/ej7_2.c b/src/guia02/ej7_2.c
@@ -1,42 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#define MAX_LEN 5    // max digits of the entered degree;
-#define ERR_MSG_LEN "El angulo ingresado contiene demasiados digitos"
-
-typedef enum {
-    AGUDO, OBTUSO, RECTO
-} angulo_t;
-
-void clean(char *buffer)
-{
-    for(size_t i = 0; i < MAX_LEN; i++)
-        buffer[i] = '\0';
-}
-
-
-int main(void) {
-    
-    char buffer[MAX_LEN];
-    int c, d, i;
-    i = 0;
-
-    while((c = getchar()) != EOF) {
-        if(c != '\n') {
-            if(i < MAX_LEN) {
-                buffer[i] = c;
-                i++;
-            } else if(i > MAX_LEN) {
-                fprintf(stderr, ERR_MSG_LEN"\n");
-                return 1;
-            }
-        }
-    i = 0;
-    d = atoi(buffer);
-    printf("%d\n", d);
-    clean(buffer);
-    }
-
-    return 0;
-}
diff --git a/src/guia02/ej8.c b/src/guia02/ej8.c
@@ -1,73 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#define MAX_LEN 5    // max digits of the entered degree;
-#define ERR_MSG_LEN "El angulo ingresado contiene demasiados digitos"
-
-#define FST_YR 48
-#define SND_YR 95
-#define TRD_YR 143
-
-
-typedef enum {
-    FIRST, SECOND, THIRD, FOURTH
-} year_t;
-
-
-void clean(char *buffer)
-{
-    for(size_t i = 0; i < MAX_LEN; i++)
-        buffer[i] = '\0';
-}
-
-
-int main(void) {
-    
-    char buffer[MAX_LEN];
-    clean(buffer);
-    int c, d, i;
-    year_t e;
-    i = 0;        
-    while(((c = getchar()) != EOF) && c != '\n') {
-        if(i < MAX_LEN) {
-            buffer[i] = c;
-            i++;
-        } else if (i >= MAX_LEN) {
-            fprintf(stderr, ERR_MSG_LEN"\n");
-            return 1;
-        }
-    }
-    d = atoi(buffer);
-
-    if (d <= FST_YR) 
-        e = FIRST;
-    else if ((d > FST_YR) && (d <= SND_YR))
-        e = SECOND;
-    else if ((d > SND_YR) && d <= (TRD_YR))
-        e = THIRD;
-    else if (d > TRD_YR) 
-        e = FOURTH;
-
-
-    switch (e)
-    {
-        case FIRST:
-            printf("Primer año\n");
-            break;
-        case SECOND:
-            printf("Segundo año\n");
-            break;
-        case THIRD:
-            printf("Tercer año\n");
-            break;
-        case FOURTH:
-            printf("Curto año o superior\n");
-            break;
-    }
-    return 0;
-}
-
-
-
-
diff --git a/src/guia02/guia02.pdf b/src/guia02/guia02.pdf
Binary files differ.