Unterprogramme



  • Wie übergebe ich in ein Unterprogramm 4 Int Zahlen???
    Wo muss ich was schreiben???
    Die 4 int zahlen heißen: verein1, verein2, tor1, tor2!!!



  • kudi120 schrieb:

    Wie übergebe ich in ein Unterprogramm 4 Int Zahlen???
    Wo muss ich was schreiben???
    Die 4 int zahlen heißen: verein1, verein2, tor1, tor2!!!

    bin mir nich ganz sicher ob die infos reichen!



  • Na des mit dem Unterprogamm hat sich schon erledigt!!! hab aber jetzt ein anderes Problem!!!
    Dieses Programm soll Eine Tabelle soll aktualisiert werden!!!
    Das Programm:

    #include "stdio.h"
    #include "string.h"
    #include "stdlib.h"
    #include "time.h"
    #include "windows.h"

    void aendern();
    void Sortieren(int &tor1, int &tor2, int &verein1, int &verein2);
    void file();

    struct Tabelle
    {int ranking;
    char verein[13];
    int punkte;
    int tores;
    char zeichen[1];
    int toreb;
    };

    struct Tabelle1
    {int ranking1;
    char verein1[13];
    int punkte1;
    int tores1;
    char zeichen1[1];
    int toreb1;
    };

    void main ()
    {
    Tabelle tABELLE;

    FILE *f;

    char a1;
    f=fopen("Tabelle.txt", "r");

    while(fscanf(f, "%d %s %d %d %c %d", &tABELLE.ranking, tABELLE.verein, &tABELLE.punkte, &tABELLE.tores, tABELLE.zeichen, &tABELLE.toreb)!=EOF)
    {
    printf("\n%i ", tABELLE.ranking);
    printf("%s\t", tABELLE.verein);
    printf("%i ", tABELLE.punkte);
    printf(" %i ", tABELLE.tores);
    printf("%c ", tABELLE.zeichen);
    printf("%i ", tABELLE.toreb);
    }
    printf("\n\n");

    printf("Wollen Sie die Punkte aendern? ");
    scanf("%s", &a1);
    if(a1=='j')
    aendern();
    else
    {}

    file();
    fcloseall();
    }

    void aendern()
    {
    int verein1, verein2, tor1, tor2;
    bool start;
    do{

    printf("\nPlatzierung des 1.Vereins: (1-10)");
    scanf("%d", &verein1);
    if(verein1==0 || verein1>=11)
    {
    printf("WARNUNG: Dieser Verein besteht nicht!!!\n\n");
    printf("Das Programm wird neu gestartet!\n\n\n");
    Sleep(2500);
    start=TRUE;
    }
    else
    {
    printf("\nPlatzierung des 2.Vereins: (1-10)");
    scanf("%d", &verein2);
    if(verein2==0 || verein2>=11)
    {
    printf("WARNUNG: Dieser Verein besteht nicht!!!\n\n");
    printf("Das Programm wird neu gestartet!\n\n\n");
    Sleep(2500);
    start=TRUE;
    }
    if(verein1==verein2)
    {
    printf("Es können nicht 2 gleiche Vereine gegeneinander spielen!!!");
    printf("Das Programm wird neu gestartet!\n\n\n");
    Sleep(2500);
    start=TRUE;
    }

    printf("\nWie ist das Spiel ausgegangen? (0, 1 od. 3)");
    printf("\nTore Verein 1: ");
    scanf("%d", &tor1);
    printf("\nTore Verein 2: ");
    scanf("%d", &tor2);
    printf("Das Spiel ist %d : %d ausgegangen!", tor1, tor2);

    printf("\n\nDie Tabelle wird aktualisiert ....\n");
    Sortieren(tor1, tor2, verein1, verein2);
    }

    }
    while(start==TRUE);

    }

    void Sortieren(int &tor1, int &tor2, int &verein1, int &verein2)
    {
    Tabelle tABELLE;
    Tabelle1 tABELLE1;
    char clubs[25];

    FILEf;
    FILE
    f1;

    f=fopen("tabelle.txt", "r");
    f1=fopen("tabelle2.txt", "w");

    while(fscanf(f, "%d %s %d %d %c %d", &tABELLE.ranking, tABELLE.verein, &tABELLE.punkte, &tABELLE.tores, tABELLE.zeichen, &tABELLE.toreb)!=EOF)
    {
    // printf("\n%i ", tABELLE.ranking);
    // printf("%s\t", tABELLE.verein);
    // printf("%i ", tABELLE.punkte);
    // printf(" %i ", tABELLE.tores);
    // printf("%c ", tABELLE.zeichen);
    // printf("%i ", tABELLE.toreb);
    if(tABELLE.ranking==verein1)
    {
    tABELLE.tores=tABELLE.tores+tor1;
    tABELLE.toreb=tABELLE.toreb+tor2;
    }
    if(tABELLE.ranking==verein2)
    {
    tABELLE.tores=tABELLE.tores+tor2;
    tABELLE.toreb=tABELLE.toreb+tor1;
    }
    }

    while(fscanf(f, "%d %s %d %d %c %d", &tABELLE1.ranking1, tABELLE1.verein1, &tABELLE1.punkte1, &tABELLE1.tores1, tABELLE1.zeichen1, &tABELLE1.toreb1)!=EOF)
    {
    printf("\n%i ", tABELLE1.ranking1);
    printf("%s\t", tABELLE1.verein1);
    printf("%i ", tABELLE1.punkte1);
    printf(" %i ", tABELLE1.tores1);
    printf("%c ", tABELLE1.zeichen1);
    printf("%i ", tABELLE1.toreb1);
    }

    while(1==1)
    {

    }
    }

    void file(void)
    {}



  • mal kurz, wie man in foren postet:

    1. Wenn du ein Problem hast, musst uns das auch sagen! Es ist schön das das Programm eine Tabelle aktualisieren soll, doch musst schon sagen was nich geht, wie der fehler lautet, was du schon probiert hast!

    2. Wenn du schon den Windowsquellcode herwirfst, mach wenigstens codetags, das jemand da durch blickt!

    3. sieht das irgendwie nach C aus


Anmelden zum Antworten