Results 1 to 7 of 7

Thread: ++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Feb:2009
    Location: .
    Posts: 11

    ++

    :
    , , . , 10 , . , :
    - , ;
    - ;
    - ( 2 ).

    :

    #include <stdio.h>
    #include <conio.h>
    struct student{
    char ime[31]; char EGN[11]; long FN; int oc[10];float sru;
    };
    FILE *fp;
    char fime[31];
    student stud;
    // vuvejdane na 1 sudent
    void readStud(student *st) {
    int i;
    printf("ime:");gets(st->ime);
    printf("egn:");gets(st->EGN);
    printf("fak.nomer:");scanf("%ld",&st->FN);
    printf("ocenki po 10 disiplini\n");
    for (i=0;i< 10;i++){
    printf("Po %d-a disciplina:",i+1);scanf("%d",&st->oc[i]);
    }
    int j,s=0;
    for(j=0;j<10;j++) s+=st->oc[j];
    st->sru=s/10.0;
    getchar();
    }

    //izvejdane na studenti
    void writeStud(student st) {
    int i;
    printf("ime: %s\n",st.ime);
    printf("egn: %s\n",st.EGN);
    printf("fak.nomer:%06ld\n",st.FN);
    printf("Ocenki: ");
    for (i=0;i<10;i++) printf("%d ",st.oc[i]);
    printf("\n");
    printf("Sreden uspeh: %4.2f\n",st.sru);
    }

    // suzdavane na fail
    void sazdaj(){
    fp=fopen(fime,"w");fclose(fp);
    printf("failut e suzdaden!\n");
    }
    //dobavqne kym failut
    void dobavi (){
    fp=fopen(fime,"a+b");
    char ch;
    do {
    readStud(&stud);
    fwrite(&stud,sizeof(stud),1,fp);
    printf("o6te (d/n)?");ch=getchar();getchar();
    }while (ch!='n');
    fclose (fp);
    }
    void spisukall() {
    int k=0;
    fp = fopen(fime,"rb");
    fread(&stud,sizeof(stud),1,fp);
    while (!feof(fp)) {
    writeStud(stud);
    k++;
    fread(&stud,sizeof(stud),1,fp);
    }
    fclose(fp);
    printf("Namereni: %d\n",k);
    }
    //glavna programa
    main () {
    char otg[3];
    printf("zadaite ime na failut:");gets(fime);
    do {
    printf(" Menu\n");
    printf(" 1. Suzdavane na prazen fail\n");
    printf(" 2. Dobavqne kum failut\n");
    printf(" 3. Obsht spisuk\n");

    printf(" Izbor (0-za krai): ");gets(otg);
    switch (otg[0]) {
    case '1':sazdaj();break;
    case '2':dobavi();break;
    case '3':spisukall();break;

    }
    }while (otg[0]!='0');
    }


    !
    " " . .

  2. #2
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366

    spisukall()
    1.
    2. , , .. [] .
    3. 2 , E-.
    4. , 1 - .
    5. 1.

    "-" 3, -, .

  3. #3
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    Quote Originally Posted by Pheoman View Post
    "-" 3, -, .
    , , .

  4. #4
    Registered User
    Join Date: Feb:2009
    Location: .
    Posts: 11
    2. , , .. [] .


  5. #5
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    Code:
    student stud; //  ,      
    int broj = 0; //     ,    
    for (int idx = 0; idx < 10; idx++)
    {
       if (stud.oc[idx] == 2)
       {
          broj++; //      1
       }
    }
    if (broj > 2)
    {
       //      2 
    }

  6. #6
    Registered User
    Join Date: Feb:2009
    Location: .
    Posts: 11
    Quote Originally Posted by Pheoman View Post
    Code:
    student stud; //  ,      
    int broj = 0; //     ,    
    for (int idx = 0; idx < 10; idx++)
    {
       if (stud.oc[idx] == 2)
       {
          broj++; //      1
       }
    }
    if (broj > 2)
    {
       //      2 
    }

    . ?

  7. #7
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    . , :
    1. broj
    2. stud

    , .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |