Advertisement
Guest User

Initializer

a guest
Oct 14th, 2012
2,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <Windows.h>
  3.  
  4. const int Size = 30;
  5. const int LSize = 3;
  6. const int TSize = 40;
  7. int Init[Size][Size][Size], Temp[Size][Size][Size];
  8. DWORD Real = 0;
  9.  
  10. void main()
  11. {
  12.     int x, y, z;
  13.     for (x = 0; x < Size; x++)
  14.         for (y = 0; y < Size; y++)
  15.             for (z = 0; z < Size; z++)
  16.             {
  17.                 if (x > (Size - TSize) / 2 && x <= (Size + TSize) / 2 && \
  18.                     y > (Size - TSize) / 2 && y <= (Size + TSize) / 2 && \
  19.                     z > (Size - TSize) / 2 && z <= (Size + TSize) / 2)
  20.                     Temp[x][y][z] = 30;
  21.                 else
  22.                     Temp[x][y][z] = 0;
  23.                 if (x > (Size - LSize) / 2 && x <= (Size + LSize) / 2 && \
  24.                     y > (Size - LSize) / 2 && y <= (Size + LSize) / 2 && \
  25.                     z > (Size - LSize) / 2 && z <= (Size + LSize) / 2)
  26.                     Init[x][y][z] = 1;
  27.                 else
  28.                     Init[x][y][z] = 0;
  29.             }
  30.     HANDLE out = CreateFileA("F:\\Разное\\Проекты\\C++\\life\\InitialTemperature.init", \
  31.         GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);   
  32.     WriteFile(out, Temp, Size * Size * Size * sizeof(int), &Real, NULL);
  33.     CloseHandle(out);
  34.  
  35.     HANDLE out1 = CreateFileA("F:\\Разное\\Проекты\\C++\\life\\InitialLife.init", \
  36.         GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);   
  37.     WriteFile(out1, Init, Size * Size * Size * sizeof(int), &Real, NULL);
  38.     CloseHandle(out1);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement