All pastes #56941 Raw Edit

Anonymous

public c v1 · immutable
#56941 ·published 2006-05-18 20:51 UTC
rendered paste body
#include <stdio.h>#define agwn 2#define apotel 4main(){        FILE *fp;        char ch,enter;        int i,j,k,count1=0,count2=0,countx=0;        int howmany;        fp=fopen("propo.txt","w");        for(i=0;i<agwn;i++)        {                howmany = 0;                printf("Dwse apotelesmata gia %di agwnistiki\n",i+1);                for(j=0;j<apotel, howmany<apotel;j++) {                        scanf("%c",&ch);                        if(ch!='1' && ch!='2' && ch!='x' && ch!='\n') {                                printf("Lathos, ksanadwse\n");                        }                        else {                             howmany++;                            putc(ch,fp);                        }                                               while (ch!='\n') {scanf("%c",&ch);}                }                putc('\n', fp);        }                fclose(fp);                fp=fopen("propo.txt","r");                ch=getc(fp);                i=0;                j=1;              while(ch!=EOF)                {                        count1=0;                        count2=0;                        countx=0;                        while(i<apotel)                        {                               if(ch=='1')                                {                                        count1++;                                }                                else if(ch=='2')                                {                                        count2++;                                }                                else                                {                                        countx++;                                }                                i++;                                ch=getc(fp);                        }                        printf("\n%di agwnistiki: assoi=%d, dipla=%d, isopalies=%d\n",j,count1,count2,countx);                        j++;                        i=0;                        ch=getc(fp);                }        fclose(fp);        system("pause");}#include <stdio.h>#define agwn 2#define apotel 4main(){        FILE *fp;        char ch,enter;        int i,j,k,count1=0,count2=0,countx=0;        int howmany;        fp=fopen("propo.txt","w");        for(i=0;i<agwn;i++)        {                howmany = 0;                printf("Dwse apotelesmata gia %di agwnistiki\n",i+1);                for(j=0;j<apotel, howmany<apotel;j++) {                        scanf("%c",&ch);                        if(ch!='1' && ch!='2' && ch!='x' && ch!='\n') {                                printf("Lathos, ksanadwse\n");                        }                        else {                             howmany++;                            putc(ch,fp);                        }                                               while (ch!='\n') {scanf("%c",&ch);}                }                putc('\n', fp);        }                fclose(fp);                fp=fopen("propo.txt","r");                ch=getc(fp);                i=0;                j=1;              while(ch!=EOF)                {                        count1=0;                        count2=0;                        countx=0;                        while(i<apotel)                        {                               if(ch=='1')                                {                                        count1++;                                }                                else if(ch=='2')                                {                                        count2++;                                }                                else                                {                                        countx++;                                }                                i++;                                ch=getc(fp);                        }                        printf("\n%di agwnistiki: assoi=%d, dipla=%d, isopalies=%d\n",j,count1,count2,countx);                        j++;                        i=0;                        ch=getc(fp);                }        fclose(fp);        system("pause");}