Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1)lathos me ti malloc,de diavazo sosta onoma kai typo
- //2)elegxos gia athroisma xriston(prepei na einai toylaxiston 1)
- //3)olo to 3
- //4)check gia 26 grammata
- //5)apodesmeusi name kai type
- //6)den afinoyme tipota ellinika
- //7)backslash n stylish changes
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- main()
- {
- //----------------arxikes diastaseis tamplo -----------------
- int dimensions=10,yes,no,flag=1,max,length;
- char yesno[4],*name,type[100];
- int i,players;
- //----------------epalitheusi gia to an thelei o xristis na paiksei me tis prokathorismens diastaseis------
- do
- {
- printf("Do you want to play by defaut dimensions(10X10)?(yes/no)");
- scanf("%s", yesno);
- yes=strcmp(yesno,"yes");
- no=strcmp(yesno,"no");
- if ((yes==0)||(no==0))
- {
- flag=0;
- }
- if (flag==1)
- {
- printf("\n Wrong input.Please choose between default dimensions(yes) and custom dimensions(no)");
- }
- }while (flag!=0);
- //---------------epalitheusi gia to oti oi custom diastaseis tha einai megaliteris i ises tou 5------
- if (no==0)
- {
- do
- {
- printf("\nChoose your own dimensions");
- scanf("%d", &dimensions);
- if (dimensions<5)
- {
- printf("\nWrong input.Please choose a number >=5");
- }
- }while(dimensions<5);
- }
- //--------------------paixtes-------------------------
- //--------------------arithmos paixton-----------------
- do
- {
- printf("\nChoose the number of players (2 or 4)");
- scanf("%d",&players);
- if (!((players==2)||(players==4)))
- {
- printf("\nWrong input.Please choose between 2 or 4");
- }
- }while(!((players==2)||(players==4)));
- //-------------------onoma kai typos paixton-----------
- name=(char*)malloc(players*101);
- for (i=0;i<players;i++)
- {
- printf("\nEnter the name of player number %d",i+1);
- scanf("%s",&name[i*101]);
- }
- max=0;
- i=0;
- while((name[i]!='\0')&&(i<101))
- {
- max++;
- i++;
- }
- length=0;
- for (i=101;i<(players*101);i=i+101)
- {
- while(name[i]!='\0')
- {
- length++;
- i++;
- }
- if (length>max)
- {
- max=length;
- }
- i=i-length;
- }
- printf("\nmax is %d",max);
- free(name);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement