Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. /* Array.c
  2.  
  3. Autor: Rabus Dominik
  4. Version: 0.1
  5. Datum: 22.10.2018
  6. Änderungen:
  7.  
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #define AE (unsigned char)142
  14. #define ae (unsigned char)132
  15. #define OE (unsigned char)153
  16. #define oe (unsigned char)148
  17. #define UE (unsigned char)154
  18. #define ue (unsigned char)129
  19.  
  20. int main()
  21. {
  22.  
  23. char startstring[5] = "start";
  24. char eingabestring[5] = "nicht";
  25.  
  26. /*
  27. do{
  28. printf("Bitte geben Sie start ein um das Programm zu starten: \n");//Check for Start parameter
  29. gets (eingabestring);
  30. printf("Deine Eingabe war %s \n",eingabestring);
  31. if (strcmp(eingabestring,startstring) == 0){
  32. printf("Du kannst nun mit Enter fortfahren, Danke \n");
  33. }
  34. }while (strcmp (eingabestring, startstring) != 0);
  35. */
  36.  
  37. void print_3D_Array(int x, int y, int z, int arr[x][y][z]) //Function for printing 3D Arrays
  38. {
  39. for (int i = 0; i < x; i++)
  40. {
  41. for (int j = 0; j < y; j++)
  42. {
  43. for (int k = 0; j < z; k++)
  44. {
  45. printf("%d\t", arr[i][j][k]);
  46. }
  47. printf("\n");
  48. }
  49. printf("\n");
  50. }
  51. }
  52.  
  53. int dimension1;
  54. int dimension2;
  55. int dimension3;
  56.  
  57. printf("W%chlen Sie die Gr%csse des Arrays: \n", 132, 148); //Userinput for Size from Arrays
  58. int check2ndnumber = scanf("%d"
  59. "%d"
  60. "%d",
  61. &dimension1, &dimension2, &dimension3);
  62. if (check2ndnumber = !3)
  63. {
  64. printf("Fehler, das ist kein Operator... \n");
  65. return 1;
  66. }
  67.  
  68. int arrayd[dimension1][dimension2][dimension3]; //3D Array
  69. int counter = 1;
  70.  
  71. //Write the Array
  72.  
  73. for (int c = 0; c < dimension1; c++)
  74. {
  75. for (int d = 0; d < dimension2; d++)
  76. {
  77. for (int e = 0; e < dimension3; e++)
  78. {
  79. arrayd[c][d][e] = counter;
  80. counter++;
  81. }
  82. }
  83. }
  84.  
  85. print_3D_Array(dimension1, dimension2, dimension3, arrayd);
  86.  
  87. system("PAUSE");
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement