PSET 1 хакер Марио код
The instructions are here: http://cdn.cs50.net/2016/x/psets/1/hacker1/hacker1.html#itsa_mario and here for the full understanding of the basic requirements: http://cdn.cs50.net/2016/x/psets/1/pset1/pset1.html#itsa_mario The problem is I get the correct output but my code isnt correct.
Check50: ) mario.c exists :) mario.c compiles :) rejects a height of -1 :) handles a height of 0 correctly :) handles a height of 1 correctly :( handles a height of 2 correctly \ expected output, but not " # # \n## ##\n" :( handles a height of 23 correctly \ expected output, but not " # # ..." :) rejects a height of 24 :) rejects a non-numeric height of "foo" :) rejects a non-numeric height of ""
МОИ РЕЗУЛЬТАТЫ
ВЫХОДЫ CS50:
Большое спасибо,
Что я уже пробовал:
Hacker Mario up vote 0 down vote favorite The instructions are here: http://cdn.cs50.net/2016/x/psets/1/hacker1/hacker1.html#itsa_mario and here for the full understanding of the basic requirements: http://cdn.cs50.net/2016/x/psets/1/pset1/pset1.html#itsa_mario The problem is I get the correct output but my code isnt correct. Check50: ) mario.c exists :) mario.c compiles :) rejects a height of -1 :) handles a height of 0 correctly :) handles a height of 1 correctly :( handles a height of 2 correctly \ expected output, but not " # # \n## ##\n" :( handles a height of 23 correctly \ expected output, but not " # # ..." :) rejects a height of 24 :) rejects a non-numeric height of "foo" :) rejects a non-numeric height of "" MY OUTPUTS My OUtputs CS50 OUTPUTS Outputs of CS50 Staff implementation Finally, my code: { int height; int i; int spaces1; int blocks1; int spaces2; int blocks2; do { printf("Height: "); height = GetInt(); if (height==0) { return 0; } } while (height < 0 || height > 23); if (height == 1) { for (i=0; i<1;i++) { for (blocks1 = 0; blocks1 < 1; blocks1++) { printf("#"); } printf(" "); for (blocks2 = 0; blocks2 < 1; blocks2++) { printf("#"); } printf("\n"); } } else { for (int a=1; a<height +1; a++) { for(spaces1 = 0; spaces1 < height-a; spaces1++) { printf(" "); } for (blocks1 = 0; blocks1 < a; blocks1++) { printf("#"); } printf(" "); for (blocks2 = 0; blocks2 < a; blocks2++) { printf("#"); } for(spaces2 = 0; spaces2 < height - a; spaces2++) { printf(" "); } printf("\n"); } }
[no name]
Умение пользоваться отладчиком по-прежнему является ценным навыком.