Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. MyStruct const table[] =
  2. {
  3. { something1, otherthing1 },
  4. // ...
  5. };
  6.  
  7. char c_arr[5][6][7];
  8.  
  9. std::array<std::array<std::array<char, 7>, 6>, 5> cpp_arr;
  10.  
  11. std::array<std::array<int, 3>, 3> arr1;
  12.  
  13. char c_arr[3][3];
  14.  
  15. //Create an array 3 x 5 (Notice the extra pair of braces)
  16.  
  17. fsma::array_2d <double, 3, 5> my2darr = {{
  18. { 32.19, 47.29, 31.99, 19.11, 11.19},
  19. { 11.29, 22.49, 33.47, 17.29, 5.01 },
  20. { 41.97, 22.09, 9.76, 22.55, 6.22 }
  21. }};
  22.  
  23. void foo(int bar) {
  24. double tempArray[bar];
  25. //Do something with the bar elements in tempArray.
  26. }
  27.  
  28. void foo(int bar) {
  29. double* tempArray = new double[bar];
  30. //Do something with the bar elements behind tempArray.
  31. delete[] tempArray;
  32. }
  33.  
  34. void smoothImage(int width, int height, int (*pixels)[width]) {
  35. int (*copy)[width] = malloc(height*sizeof(*copy));
  36. memcpy(copy, pixels, height*sizeof(*copy));
  37. for(y = height; y--; ) {
  38. for(x = width; x--; ) {
  39. pixels[y][x] = //compute smoothed value based on data around copy[y][x]
  40. }
  41. }
  42. free(copy);
  43. }
  44.  
  45. void smoothImage(int width, int height, int* pixels) {
  46. int* copy = new int[height*width];
  47. memcpy(copy, pixels, height*width*sizeof(*copy));
  48. for(y = height; y--; ) {
  49. for(x = width; x--; ) {
  50. pixels[y*width + x] = //compute smoothed value based on data around copy[y*width + x]
  51. }
  52. }
  53. delete[] copy;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement