#include #define N 80 #include int main (int argc, char* argv[]) { int mikos, prosp,thesi, i, j, metritis,prospstath,z,b; /*pros=prospa8eies, str1 to string me paules, ab ta grammata tis agglikis alfavitou, abstable osa grammata emeinan*/ char str[N], str1[N], ab[26], read,lathos; /*diavazw argotera ena xaraktira parapanw, gi auto kanw mia scanf pou vazei auton ton xaraktira mesa*/ printf("dwste tin mistiki leksi\n"); scanf("%79s", str); system ("cls"); for (i=0; str[i]!='\0'; i++) {} mikos=i-1; /*vrika to telos tou string kai to vazw sto meikos*/ prosp=(mikos*2)+2; prospstath=prosp; /*i prosp allazei, opote ftiaxnw tin prospsta8 wste na min allazei*/ for (i=0; i<=mikos; i++) /*to str1 exei oses 8eseis kai to str alla me asterakia*/ {str1[i]='-'; } ab[0]='a'; ab[1]='b'; ab[2]='c'; ab[3]='d'; ab[4]='e'; ab[5]='f'; ab[6]='g'; ab[7]='h'; ab[8]='i'; ab[9]='j'; ab[10]='k'; ab[11]='l'; ab[12]='m'; ab[13]='n'; ab[14]='o'; ab[15]='p'; ab[16]='q'; ab[17]='r'; ab[18]='s'; ab[19]='t'; ab[20]='u'; ab[21]='v'; ab[22]='w'; ab[23]='x'; ab[24]='y'; ab[25]='z' ; /*gemizw pinakes me alfa vita*/ printf("Paixti 2, exeis %d prospa8eies\n", prosp); printf("ta grammata pou sou emeinan einai:\n"); for (i=0; i<26; i++) {printf("%c", ab[i]); printf(" ");} printf("\ni frasi einai\n"); printf("%s\n", str1); printf("dwse gramma\n"); scanf("%c", &lathos); scanf("%c", &read); system ("cls"); thesi=-1; /*apokleietai i thesi tou grammatos stin alfa vita na einai -1*/ metritis=0; for (j=1; j<=prospstath; j++) { for (i=0; i<26; i++) {if (read==ab[i]) { thesi=i; ab[i]=' '; } } while (thesi==-1) { system ("cls"); printf("den dosate ena apo ta dia8esima grammata, i gramma genikotera\n"); /*periptwsi error*/ printf("dwse gramma\n"); scanf("%c", &lathos); scanf("%c", &read); for (i=0; i<26; i++) {if (read==ab[i]) { thesi=i; ab[i]=' '; } } } b=0; for (i=0; i<=mikos; i++) /*vazw to gramma anti gia _*/ { if (read==str[i]) {str1[i]=read; b=1; metritis++; }} if (b==0) {prosp--;} /*b metritis gia na meiw8oun oi prospa8eies*/ z=prospstath-prosp; if (metritis==(mikos+1)) {printf("bravo, to vrikes, me %d prospa8eies!", z); break;} if (prosp==0) {printf("kaikes! xoxoxo xaxa xo!"); break; } printf("Paixti 2, exeis %d prospa8eies\n", prosp); printf("ta grammata pou sou emeinan einai:\n"); for (i=0; i<26; i++) {printf("%c", ab[i]); printf(" ");} printf("\ni frasi einai\n"); printf("%s\n", str1); printf("dwse gramma\n"); scanf("%c", &lathos); scanf("%c", &read); system ("cls"); thesi=-1; } printf("\n"); system("pause"); return(0); }