Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. //1)lathos me ti malloc,de diavazo sosta onoma kai typo
  2. //2)elegxos gia athroisma xriston(prepei na einai toylaxiston 1)
  3. //3)olo to 3
  4. //4)check gia 26 grammata
  5. //5)apodesmeusi name kai type
  6. //6)den afinoyme tipota ellinika
  7. //7)backslash n stylish changes
  8.  
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. main()
  13. {
  14. //----------------arxikes diastaseis tamplo -----------------
  15. int dimensions=10,yes,no,flag=1,max,length;
  16. char yesno[4],*name,type[100];
  17. int i,players;
  18. //----------------epalitheusi gia to an thelei o xristis na paiksei me tis prokathorismens diastaseis------
  19. do
  20. {
  21. printf("Do you want to play by defaut dimensions(10X10)?(yes/no)");
  22. scanf("%s", yesno);
  23. yes=strcmp(yesno,"yes");
  24. no=strcmp(yesno,"no");
  25. if ((yes==0)||(no==0))
  26. {
  27. flag=0;
  28. }
  29. if (flag==1)
  30. {
  31. printf("\n Wrong input.Please choose between default dimensions(yes) and custom dimensions(no)");
  32. }
  33. }while (flag!=0);
  34. //---------------epalitheusi gia to oti oi custom diastaseis tha einai megaliteris i ises tou 5------
  35. if (no==0)
  36. {
  37. do
  38. {
  39. printf("\nChoose your own dimensions");
  40. scanf("%d", &dimensions);
  41. if (dimensions<5)
  42. {
  43. printf("\nWrong input.Please choose a number >=5");
  44. }
  45. }while(dimensions<5);
  46. }
  47. //--------------------paixtes-------------------------
  48. //--------------------arithmos paixton-----------------
  49. do
  50. {
  51. printf("\nChoose the number of players (2 or 4)");
  52. scanf("%d",&players);
  53. if (!((players==2)||(players==4)))
  54. {
  55. printf("\nWrong input.Please choose between 2 or 4");
  56. }
  57. }while(!((players==2)||(players==4)));
  58. //-------------------onoma kai typos paixton-----------
  59. name=(char*)malloc(players*101);
  60. for (i=0;i<players;i++)
  61. {
  62. printf("\nEnter the name of player number %d",i+1);
  63. scanf("%s",&name[i*101]);
  64. }
  65. max=0;
  66. i=0;
  67. while((name[i]!='\0')&&(i<101))
  68. {
  69. max++;
  70. i++;
  71. }
  72. length=0;
  73. for (i=101;i<(players*101);i=i+101)
  74. {
  75. while(name[i]!='\0')
  76. {
  77. length++;
  78. i++;
  79. }
  80. if (length>max)
  81. {
  82. max=length;
  83. }
  84. i=i-length;
  85. }
  86. printf("\nmax is %d",max);
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. free(name);
  94.  
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement