fork download
  1. #include<stdio.h>
  2. #include<time.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5. using namespace std;
  6.  
  7. int get_rand(){
  8. return rand();
  9. }
  10.  
  11. int get_num(char tar[]){
  12. if(strcmp(tar,"개") == 0) return 0;
  13. else if(strcmp(tar,"말") == 0) return 1;
  14. else if(strcmp(tar,"소") == 0) return 2;
  15. else if(strcmp(tar,"돼지") == 0) return 3;
  16. else if(strcmp(tar,"닭") == 0) return 4;
  17. else return -1;
  18. }
  19.  
  20. void print_ani(int tar){
  21. switch(tar){
  22. case 0: printf("개"); return;
  23. case 1: printf("말"); return;
  24. case 2: printf("소"); return;
  25. case 3: printf("돼지"); return;
  26. case 4: printf("닭"); return;
  27. default: printf("ERR"); return;
  28. }
  29. }
  30.  
  31. void init(){
  32. srand(time(NULL));
  33. }
  34.  
  35.  
  36. enum {dog,horse,cow,pig,chicken} ani;
  37. //개=0, 말=1, 소=2, 돼지=3, 닭=4
  38.  
  39. int cnt[5];
  40. int voted[55][2];
  41.  
  42. int main(){
  43. //freopen("input.txt","r",stdin);
  44. //freopen("output.txt","w",stdout);
  45.  
  46. init();
  47.  
  48. for(int iter=0;;iter++){
  49. char nick[55];
  50. char t1[5], t2[5];
  51.  
  52. if(scanf("%s %s %s",nick,t1,t2)==EOF) break;
  53. int c1 = get_num(t1), c2 = get_num(t2);
  54. voted[iter][0] = c1; voted[iter][1] = c2;
  55.  
  56. for(int aniter=0; aniter<5; aniter++){
  57. if(aniter==c1 || aniter==c2) continue;
  58.  
  59. int rnd = get_rand();
  60. bool isGo;
  61. if(rnd % 2 == 1) isGo = true;
  62. else isGo = false;
  63.  
  64. if(isGo) cnt[aniter]++;
  65.  
  66. print_ani(aniter);
  67. printf("에게 %s님께서 여물을 주",nick);
  68. if(isGo == false) printf("었지만 전진하지 않았습니다.");
  69. else printf("어서 전진하였습니다.");
  70. printf("\n");
  71. }
  72. printf("\n");
  73. }
  74.  
  75. printf("\n전진한 칸 수: \n");
  76. for(int aniter = 0; aniter < 5; aniter++){
  77. print_ani(aniter);
  78. printf(": %d", cnt[aniter]);
  79. if(aniter != 5-1) printf(", ");
  80. }
  81.  
  82.  
  83. return 0;
  84. }
  85.  
Success #stdin #stdout 0s 15240KB
stdin
gyeryak 개 돼지
vimva 소 닭
hwantag 돼지 말
asbear 돼지 닭
stdout
말에게 gyeryak님께서 여물을 주어서 전진하였습니다.
소에게 gyeryak님께서 여물을 주어서 전진하였습니다.
닭에게 gyeryak님께서 여물을 주었지만 전진하지 않았습니다.

개에게 vimva님께서 여물을 주었지만 전진하지 않았습니다.
말에게 vimva님께서 여물을 주어서 전진하였습니다.
돼지에게 vimva님께서 여물을 주었지만 전진하지 않았습니다.

개에게 hwantag님께서 여물을 주어서 전진하였습니다.
소에게 hwantag님께서 여물을 주어서 전진하였습니다.
닭에게 hwantag님께서 여물을 주어서 전진하였습니다.

개에게 asbear님께서 여물을 주어서 전진하였습니다.
말에게 asbear님께서 여물을 주었지만 전진하지 않았습니다.
소에게 asbear님께서 여물을 주었지만 전진하지 않았습니다.


전진한 칸 수: 
개: 2, 말: 2, 소: 2, 돼지: 0, 닭: 1