Guest User

Untitled

a guest
Jan 4th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define MAX 25
  6. #define maxArrayLength 26
  7.  
  8. int main(int argc, char * argv[]){
  9. //Stage 1 Variables
  10. int time = 0;
  11. int edge;
  12. //int m;
  13. int matrix[MAX][MAX];
  14. int i,j;
  15. int timeStep = 0; //change names
  16. int windDirection; //change names
  17. int c = 0; //change name
  18. //int a = 0;
  19. char alpha[] = {"abcdefghiklmnopqrstuvwxy"};
  20. //char alpha[25] = {'a','b','c','d','e','f','g','h','i','j','k','l','m'
  21. //,'n','o','p','q','r','s','t','u','v','w','x','y'};
  22. //int numbers [] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
  23. //20,21,22,23,24};
  24.  
  25. printf("Enter t : ");
  26. scanf("%d",&time);
  27. if (time < 0 || time > 1000) {
  28. printf("Incorrect Input: t must be 0..1000\n");
  29. } printf("Enter n : ");
  30. scanf("%d", &edge);
  31. if (edge < 3 || edge > 25) {
  32. printf("Incorrect Input: n must be 3..25\n");
  33. }
  34. printf("Enter %d by %d forest :\n", edge, edge);
  35. for(i = 0; i < edge; i++){
  36. for(j = 0; j < edge; j++){
  37. scanf("%d",&matrix[i][j]);
  38. }
  39. }
  40. printf("Enter wind direction information :\n");
  41. scanf("%d %d", &timeStep, &windDirection);
  42. //get it to scan in numbers till a letter and every second number
  43. //starting from fisrt is timestep, then every second one starting from
  44. //the 2nd is direction.
  45.  
  46. //Stage 1
  47. printf("Time step %d: Wind ", timeStep);
  48. if(windDirection==0){
  49. printf("NORTH\n");
  50. } else if (windDirection==1){
  51. printf("EAST\n");
  52. } else if (windDirection==2){
  53. printf("SOUTH\n");
  54. } else if (windDirection==3){
  55. printf("WEST\n");
  56. }
  57. //print the length of string, i.e. 5 is e
  58. //for (alpha=0; alpha < edge; alpha++);//print edge length + 2
  59. int counter = 0;
  60. while (counter < edge) {
  61. int x = 0;
  62. x = (edge % 25);
  63. printf ("%c", alpha[x]);
  64. }
  65.  
  66. for(i=0; i < edge; i++){
  67. printf("# "); //left side
  68. for(j=0; j < edge; j++){
  69. if(matrix[i][j] == 0){
  70. printf(". ");
  71. }else if(matrix[i][j] == 1){
  72. printf("^ ");
  73. }else{
  74. printf("* ");
  75. }
  76. }
  77. printf("#\n");
  78. }
  79. printf("# # # # #\n"); //print edge length + 2
  80.  
  81. printf("Number of cells containing trees in initial forest = %d\n", c); //count the number of ones
  82. printf("Number of cells that have burned down = 0\n"); //first stage
  83. printf("Percentage of forest burned down = 0.00\n"); //number of . /
  84.  
  85. return 0;
  86. }
Add Comment
Please, Sign In to add comment