mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-31 01:08:25 +04:00
commit everything lol
This commit is contained in:
parent
f2428d8bb6
commit
0c32b4dd13
@ -105,6 +105,7 @@
|
|||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)\include</AdditionalIncludeDirectories>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -122,7 +123,7 @@
|
|||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)\include;</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)\include;</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard_C>Default</LanguageStandard_C>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
@ -139,13 +140,16 @@
|
|||||||
<ClInclude Include="..\include\raymath.h" />
|
<ClInclude Include="..\include\raymath.h" />
|
||||||
<ClInclude Include="..\include\resource_dir.h" />
|
<ClInclude Include="..\include\resource_dir.h" />
|
||||||
<ClInclude Include="..\include\tinyfiledialogs.h" />
|
<ClInclude Include="..\include\tinyfiledialogs.h" />
|
||||||
|
<ClInclude Include="..\src\dynamic_memory.h" />
|
||||||
<ClInclude Include="..\src\game.h" />
|
<ClInclude Include="..\src\game.h" />
|
||||||
<ClInclude Include="..\src\parallel_for.h" />
|
<ClInclude Include="..\src\memory_arena.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\src\dynamic_memory.c" />
|
||||||
<ClCompile Include="..\src\game.c" />
|
<ClCompile Include="..\src\game.c" />
|
||||||
|
<ClCompile Include="..\src\gol_threading.c" />
|
||||||
<ClCompile Include="..\src\main.c" />
|
<ClCompile Include="..\src\main.c" />
|
||||||
<ClCompile Include="..\src\parallel_for.c" />
|
<ClCompile Include="..\src\memory_arena.c" />
|
||||||
<ClCompile Include="..\src\tinyfiledialogs.c" />
|
<ClCompile Include="..\src\tinyfiledialogs.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
@ -33,7 +33,10 @@
|
|||||||
<ClInclude Include="..\src\game.h">
|
<ClInclude Include="..\src\game.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\src\parallel_for.h">
|
<ClInclude Include="..\src\dynamic_memory.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\src\memory_arena.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -47,7 +50,13 @@
|
|||||||
<ClCompile Include="..\src\game.c">
|
<ClCompile Include="..\src\game.c">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\parallel_for.c">
|
<ClCompile Include="..\src\dynamic_memory.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\memory_arena.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\src\gol_threading.c">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
31
Game of Life/src/dynamic_memory.c
Normal file
31
Game of Life/src/dynamic_memory.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void* SafeMalloc(size_t size)
|
||||||
|
{
|
||||||
|
void* buffer = malloc(size);
|
||||||
|
if (buffer == NULL) {
|
||||||
|
fprintf(stderr, "Error in SafeMalloc: failed to allocate %zu bytes.\n", size);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* SafeCalloc(size_t count, size_t size)
|
||||||
|
{
|
||||||
|
void* buffer = calloc(count, size);
|
||||||
|
if (buffer == NULL) {
|
||||||
|
fprintf(stderr, "Error in SafeCalloc: failed to allocate %zu bytes.\n", count * size);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* SafeRealloc(void* block, size_t size) {
|
||||||
|
void* buffer = realloc(block, size);
|
||||||
|
if (buffer == NULL) {
|
||||||
|
fprintf(stderr, "Error in SafeRealloc: failed to reallocate block %p of %zu bytes.\n", block, size);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
5
Game of Life/src/dynamic_memory.h
Normal file
5
Game of Life/src/dynamic_memory.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void* SafeMalloc(size_t size);
|
||||||
|
void* SafeCalloc(size_t count, size_t size);
|
||||||
|
void* SafeRealloc(void* block, size_t size);
|
53
Game of Life/src/gol_threading.c
Normal file
53
Game of Life/src/gol_threading.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
//#include <stdbool.h>
|
||||||
|
//#include <string.h>
|
||||||
|
//#include <iso646.h>
|
||||||
|
//
|
||||||
|
//typedef struct {
|
||||||
|
// bool** map;
|
||||||
|
// bool** tempMap;
|
||||||
|
// int startX;
|
||||||
|
// int endX;
|
||||||
|
// int startY;
|
||||||
|
// int endY;
|
||||||
|
//} golArgs;
|
||||||
|
|
||||||
|
//static inline int checkCell(int x, int y) {
|
||||||
|
// if (x < 0 or y < 0 or x > MAP_X - 1 or y > MAP_Y - 1) {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// return map[x][y];
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void celluralAutomata()
|
||||||
|
//{
|
||||||
|
// for (int x = 0; x < MAP_X; x++) {
|
||||||
|
// for (int y = 0; y < MAP_Y; y++) {
|
||||||
|
// int neighbours = 0;
|
||||||
|
//
|
||||||
|
// neighbours += checkCell(x - 1, y);
|
||||||
|
// neighbours += checkCell(x - 1, y + 1);
|
||||||
|
// neighbours += checkCell(x - 1, y - 1);
|
||||||
|
// neighbours += checkCell(x + 1, y);
|
||||||
|
// neighbours += checkCell(x + 1, y + 1);
|
||||||
|
// neighbours += checkCell(x + 1, y - 1);
|
||||||
|
// neighbours += checkCell(x, y + 1);
|
||||||
|
// neighbours += checkCell(x, y - 1);
|
||||||
|
//
|
||||||
|
// if (neighbours == 3) {
|
||||||
|
// tempMap[x][y] = true;
|
||||||
|
// }
|
||||||
|
// else if (neighbours == 2) {
|
||||||
|
// tempMap[x][y] = map[x][y];
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// tempMap[x][y] = false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for (int x = 0; x < MAP_X; x++) {
|
||||||
|
// memcpy(map[x], tempMap[x], MAP_Y * sizeof(bool));
|
||||||
|
// }
|
||||||
|
//}
|
@ -3,21 +3,20 @@
|
|||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
#include "resource_dir.h"
|
#include "resource_dir.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <iso646.h>
|
#include <iso646.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <threads.h>
|
||||||
|
|
||||||
#include "parallel_for.h"
|
#include "dynamic_memory.h"
|
||||||
|
#include "memory_arena.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define MAP_X 1200
|
||||||
#include "raygui.h"
|
#define MAP_Y 600
|
||||||
|
#define CELL_SIZE 2
|
||||||
#define MAP_X 400
|
|
||||||
#define MAP_Y 200
|
|
||||||
#define CELL_SIZE 6
|
|
||||||
#define FCELL_SIZE (float)CELL_SIZE
|
#define FCELL_SIZE (float)CELL_SIZE
|
||||||
|
|
||||||
#define BOTTOM_BAR_HEIGHT 60
|
#define BOTTOM_BAR_HEIGHT 60
|
||||||
|
|
||||||
#define PUREBLUE CLITERAL(Color){ 0, 0, 255, 255 }
|
#define PUREBLUE CLITERAL(Color){ 0, 0, 255, 255 }
|
||||||
@ -25,275 +24,379 @@
|
|||||||
#define VSGREEN CLITERAL(Color){78, 201, 176, 255}
|
#define VSGREEN CLITERAL(Color){78, 201, 176, 255}
|
||||||
#define WATERBLUE CLITERAL(Color){200, 240, 255, 255}
|
#define WATERBLUE CLITERAL(Color){200, 240, 255, 255}
|
||||||
|
|
||||||
//static bool map[MAP_X][MAP_Y] = { 0 };
|
|
||||||
//static bool tempMap[MAP_X][MAP_Y] = { 0 };
|
|
||||||
|
|
||||||
bool** map;
|
bool** map;
|
||||||
bool** tempMap;
|
bool** tempMap;
|
||||||
|
|
||||||
void* SafeMalloc(size_t size)
|
typedef struct {
|
||||||
|
bool** map;
|
||||||
|
bool** tempMap;
|
||||||
|
int startX;
|
||||||
|
int endX;
|
||||||
|
int startY;
|
||||||
|
int endY;
|
||||||
|
} golArgs;
|
||||||
|
|
||||||
|
thrd_t threads[32];
|
||||||
|
golArgs thread_args[32];
|
||||||
|
int numThreads = 5;
|
||||||
|
|
||||||
|
static inline int checkCell(int x, int y)
|
||||||
{
|
{
|
||||||
void* buffer = malloc(size);
|
if (x < 0 or y < 0 or x > MAP_X - 1 or y > MAP_Y - 1) {
|
||||||
if (buffer == NULL) {
|
return 0;
|
||||||
fprintf(stderr, "Error in SafeMalloc: failed to allocate %zu bytes.\n", size);
|
}
|
||||||
abort();
|
else {
|
||||||
}
|
return map[x][y];
|
||||||
return buffer;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* SafeCalloc(size_t count, size_t size)
|
static inline single_gol(int x, int y)
|
||||||
{
|
{
|
||||||
void* buffer = calloc(count, size);
|
int neighbours = 0;
|
||||||
if (buffer == NULL) {
|
|
||||||
fprintf(stderr, "Error in SafeCalloc: failed to allocate %zu bytes.\n", count * size);
|
neighbours += checkCell(x - 1, y);
|
||||||
abort();
|
neighbours += checkCell(x - 1, y + 1);
|
||||||
}
|
neighbours += checkCell(x - 1, y - 1);
|
||||||
return buffer;
|
neighbours += checkCell(x + 1, y);
|
||||||
|
neighbours += checkCell(x + 1, y + 1);
|
||||||
|
neighbours += checkCell(x + 1, y - 1);
|
||||||
|
neighbours += checkCell(x, y + 1);
|
||||||
|
neighbours += checkCell(x, y - 1);
|
||||||
|
|
||||||
|
if (neighbours == 2) {
|
||||||
|
tempMap[x][y] = map[x][y];
|
||||||
|
}
|
||||||
|
else if (neighbours == 3) {
|
||||||
|
tempMap[x][y] = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tempMap[x][y] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int checkCell(int x, int y) {
|
int gol_thread(void* arg_ptr)
|
||||||
if (x < 0 or y < 0 or x > MAP_X - 1 or y > MAP_Y - 1) {
|
{
|
||||||
return 0;
|
golArgs args = *(golArgs*)(arg_ptr);
|
||||||
}
|
|
||||||
else {
|
for (int x = args.startX; x < args.endX; x++) {
|
||||||
return map[x][y];
|
for (int y = args.startY; y < args.endY; y++) {
|
||||||
}
|
int neighbours = 0;
|
||||||
|
|
||||||
|
neighbours += checkCell(x - 1, y);
|
||||||
|
neighbours += checkCell(x - 1, y + 1);
|
||||||
|
neighbours += checkCell(x - 1, y - 1);
|
||||||
|
neighbours += checkCell(x + 1, y);
|
||||||
|
neighbours += checkCell(x + 1, y + 1);
|
||||||
|
neighbours += checkCell(x + 1, y - 1);
|
||||||
|
neighbours += checkCell(x, y + 1);
|
||||||
|
neighbours += checkCell(x, y - 1);
|
||||||
|
|
||||||
|
if (neighbours == 2) {
|
||||||
|
tempMap[x][y] = map[x][y];
|
||||||
|
}
|
||||||
|
else if (neighbours == 3) {
|
||||||
|
tempMap[x][y] = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tempMap[x][y] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
single_gol(args.startX, args.startY);
|
||||||
|
single_gol(args.startX, args.endY);
|
||||||
|
single_gol(args.endX, args.startY);
|
||||||
|
single_gol(args.endX, args.endY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gol_thread_init() {
|
||||||
|
int deltaX = MAP_X / numThreads;
|
||||||
|
int remainder = MAP_X % numThreads;
|
||||||
|
|
||||||
|
for (int i = 0; i < numThreads - 1; i++) {
|
||||||
|
thread_args[i] = (golArgs){
|
||||||
|
.startX = deltaX * i,
|
||||||
|
.endX = deltaX * (i + 1),
|
||||||
|
.startY = 0,
|
||||||
|
.endY = MAP_Y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
thread_args[numThreads - 1] = (golArgs){
|
||||||
|
.startX = deltaX * (numThreads - 1),
|
||||||
|
.endX = MAP_X,
|
||||||
|
.startY = 0,
|
||||||
|
.endY = MAP_Y
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void gol_thread_start()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numThreads; i++) {
|
||||||
|
thrd_create(&threads[i], gol_thread, &thread_args[i]);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < numThreads; i++) {
|
||||||
|
thrd_join(threads[i], NULL);
|
||||||
|
}
|
||||||
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
|
memcpy(map[x], tempMap[x], MAP_Y * sizeof(bool));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void celluralAutomata()
|
void celluralAutomata()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < MAP_X; x++) {
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
for (int y = 0; y < MAP_Y; y++) {
|
for (int y = 0; y < MAP_Y; y++) {
|
||||||
int neighbours = 0;
|
int neighbours = 0;
|
||||||
|
|
||||||
neighbours += checkCell(x - 1, y);
|
neighbours += checkCell(x - 1, y);
|
||||||
neighbours += checkCell(x - 1, y + 1);
|
neighbours += checkCell(x - 1, y + 1);
|
||||||
neighbours += checkCell(x - 1, y - 1);
|
neighbours += checkCell(x - 1, y - 1);
|
||||||
neighbours += checkCell(x + 1, y);
|
neighbours += checkCell(x + 1, y);
|
||||||
neighbours += checkCell(x + 1, y + 1);
|
neighbours += checkCell(x + 1, y + 1);
|
||||||
neighbours += checkCell(x + 1, y - 1);
|
neighbours += checkCell(x + 1, y - 1);
|
||||||
neighbours += checkCell(x, y + 1);
|
neighbours += checkCell(x, y + 1);
|
||||||
neighbours += checkCell(x, y - 1);
|
neighbours += checkCell(x, y - 1);
|
||||||
|
|
||||||
if (neighbours == 3) {
|
if (neighbours == 3) {
|
||||||
tempMap[x][y] = true;
|
tempMap[x][y] = true;
|
||||||
}
|
}
|
||||||
else if (neighbours == 2) {
|
else if (neighbours == 2) {
|
||||||
tempMap[x][y] = map[x][y];
|
tempMap[x][y] = map[x][y];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tempMap[x][y] = false;
|
tempMap[x][y] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x = 0; x < MAP_X; x++) {
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
memcpy(map[x], tempMap[x], MAP_Y * sizeof(bool));
|
memcpy(map[x], tempMap[x], MAP_Y * sizeof(bool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//int compute_cell(int x) {
|
|
||||||
// int neighbours = 0;
|
|
||||||
//
|
|
||||||
// neighbours += checkCell(x - 1, y);
|
|
||||||
// neighbours += checkCell(x - 1, y + 1);
|
|
||||||
// neighbours += checkCell(x - 1, y - 1);
|
|
||||||
// neighbours += checkCell(x + 1, y);
|
|
||||||
// neighbours += checkCell(x + 1, y + 1);
|
|
||||||
// neighbours += checkCell(x + 1, y - 1);
|
|
||||||
// neighbours += checkCell(x, y + 1);
|
|
||||||
// neighbours += checkCell(x, y - 1);
|
|
||||||
//
|
|
||||||
// if (neighbours == 3) {
|
|
||||||
// tempMap[x][y] = true;
|
|
||||||
// }
|
|
||||||
// else if (neighbours == 2) {
|
|
||||||
// tempMap[x][y] = map[x][y];
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// tempMap[x][y] = false;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void* compute_cell_forp(void* arg)
|
|
||||||
//{
|
|
||||||
// int* pa = (int*)arg;
|
|
||||||
// int* result = malloc(sizeof(*result));
|
|
||||||
// *result = mult2(*pa);
|
|
||||||
// return result;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void ClearMap() {
|
void ClearMap() {
|
||||||
for (int x = 0; x < MAP_X; x++) {
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
memset(map[x], 0, MAP_Y * sizeof(bool));
|
memset(map[x], 0, MAP_Y * sizeof(bool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMap()
|
void drawMap()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < MAP_X; x++) {
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
for (int y = 0; y < MAP_Y; y++) {
|
for (int y = 0; y < MAP_Y; y++) {
|
||||||
if (map[x][y]) {
|
if (map[x][y]) {
|
||||||
int posX = x * CELL_SIZE;
|
int posX = x * CELL_SIZE;
|
||||||
int posY = y * CELL_SIZE;
|
int posY = y * CELL_SIZE;
|
||||||
DrawRectangle(posX, posY, CELL_SIZE, CELL_SIZE, BLACK);
|
DrawRectangle(posX, posY, CELL_SIZE, CELL_SIZE, BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawNet() {
|
void drawNet() {
|
||||||
for (int i = 0; i <= MAP_X * CELL_SIZE; i += CELL_SIZE) {
|
for (int i = 0; i <= MAP_X * CELL_SIZE; i += CELL_SIZE) {
|
||||||
DrawLine(i, 0, i, MAP_Y * CELL_SIZE, GRAY);
|
DrawLine(i, 0, i, MAP_Y * CELL_SIZE, GRAY);
|
||||||
DrawLine(i+1, 0, i+1, MAP_Y * CELL_SIZE, GRAY);
|
DrawLine(i+1, 0, i+1, MAP_Y * CELL_SIZE, GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= MAP_Y * CELL_SIZE; i += CELL_SIZE) {
|
for (int i = 0; i <= MAP_Y * CELL_SIZE; i += CELL_SIZE) {
|
||||||
DrawLine(0, i, MAP_X * CELL_SIZE, i, GRAY);
|
DrawLine(0, i, MAP_X * CELL_SIZE, i, GRAY);
|
||||||
DrawLine(0, i-1, MAP_X * CELL_SIZE, i-1, GRAY);
|
DrawLine(0, i-1, MAP_X * CELL_SIZE, i-1, GRAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawBottomBar()
|
void drawBottomBar()
|
||||||
{
|
{
|
||||||
DrawRectangle(0, MAP_Y * CELL_SIZE, MAP_X * CELL_SIZE, BOTTOM_BAR_HEIGHT, BLACKGRAY);
|
DrawRectangle(0, MAP_Y * CELL_SIZE, MAP_X * CELL_SIZE, BOTTOM_BAR_HEIGHT, BLACKGRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CPSIZE 213
|
#define CPSIZE 213
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
map = (bool**)SafeMalloc(MAP_X * sizeof(bool*));
|
map = (bool**)SafeMalloc(MAP_X * sizeof(bool*));
|
||||||
tempMap = (bool**)SafeMalloc(MAP_X * sizeof(bool*));
|
tempMap = (bool**)SafeMalloc(MAP_X * sizeof(bool*));
|
||||||
for (int x = 0; x < MAP_X; x++) {
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
map[x] = (bool*)SafeCalloc(MAP_Y, sizeof(bool));
|
map[x] = (bool*)SafeCalloc(MAP_Y, sizeof(bool));
|
||||||
tempMap[x] = (bool*)SafeCalloc(MAP_Y, sizeof(bool));
|
tempMap[x] = (bool*)SafeCalloc(MAP_Y, sizeof(bool));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int screenWidth = MAP_X * CELL_SIZE;
|
gol_thread_init();
|
||||||
const int screenHeight = MAP_Y * CELL_SIZE + BOTTOM_BAR_HEIGHT;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "Game of Life");
|
/*Arena arena = ArenaCreate(SafeCalloc(1024 * 1024, 1), 1024 * 1024);
|
||||||
|
map = (bool**)ArenaAlloc(&arena, MAP_X * sizeof(bool*));
|
||||||
|
tempMap = (bool**)ArenaAlloc(&arena, MAP_X * sizeof(bool*));
|
||||||
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
|
map[x] = (bool*)ArenaAlloc(&arena, MAP_Y * sizeof(bool));
|
||||||
|
tempMap[x] = (bool*)ArenaAlloc(&arena, MAP_Y * sizeof(bool));
|
||||||
|
}*/
|
||||||
|
|
||||||
SearchAndSetResourceDir("resources");
|
const int screenWidth = MAP_X * CELL_SIZE;
|
||||||
|
const int screenHeight = MAP_Y * CELL_SIZE + BOTTOM_BAR_HEIGHT;
|
||||||
|
|
||||||
int codepoints[CPSIZE] = { 0 };
|
SetConfigFlags(FLAG_VSYNC_HINT);
|
||||||
for (int i = 0; i < 127 - 32; i++) codepoints[i] = 32 + i; // Basic ASCII characters
|
|
||||||
for (int i = 0; i < 118; i++) codepoints[95 + i] = 1024 + i; // Cyrillic characters
|
|
||||||
|
|
||||||
Font InconsolataBold = LoadFontEx("Inconsolata-LGC-Bold.ttf", 36, codepoints, CPSIZE);
|
InitWindow(screenWidth, screenHeight, "Game of Life");
|
||||||
SetTextureFilter(InconsolataBold.texture, TEXTURE_FILTER_BILINEAR);
|
|
||||||
|
|
||||||
GuiSetFont(InconsolataBold);
|
int monitor = GetCurrentMonitor();
|
||||||
GuiSetStyle(DEFAULT, TEXT_SIZE, (int)(24));
|
int monitorFPS = GetMonitorRefreshRate(monitor);
|
||||||
GuiSetStyle(DEFAULT, TEXT_SPACING, 0);
|
|
||||||
GuiSetStyle(DEFAULT, TEXT_LINE_SPACING, (int)(24));
|
|
||||||
GuiSetStyle(STATUSBAR, BORDER_WIDTH, 2);
|
|
||||||
|
|
||||||
int monitor = GetCurrentMonitor();
|
SetTargetFPS(monitorFPS);
|
||||||
int monitorFPS = GetMonitorRefreshRate(monitor);
|
|
||||||
|
|
||||||
SetTargetFPS(monitorFPS);
|
SearchAndSetResourceDir("resources");
|
||||||
|
|
||||||
Vector2 mousePos = { 0 };
|
int codepoints[CPSIZE] = { 0 };
|
||||||
int mouseCellX = 0;
|
for (int i = 0; i < 127 - 32; i++) codepoints[i] = 32 + i; // Basic ASCII characters
|
||||||
int mouseCellY = 0;
|
for (int i = 0; i < 118; i++) codepoints[95 + i] = 1024 + i; // Cyrillic characters
|
||||||
|
|
||||||
bool editMap = true;
|
Font InconsolataBold = LoadFontEx("Inconsolata-LGC-Bold.ttf", 36, codepoints, CPSIZE);
|
||||||
bool netToggle = false;
|
SetTextureFilter(InconsolataBold.texture, TEXTURE_FILTER_BILINEAR);
|
||||||
|
|
||||||
float simSpeed = 1.0f;
|
Vector2 mousePos = { 0 };
|
||||||
int frameCounter = 0;
|
Vector2 mouseWorldPos = { 0 };
|
||||||
|
int mouseWorldCellX = 0;
|
||||||
|
int mouseWorldCellY = 0;
|
||||||
|
|
||||||
int guyScreenWidth = 720;
|
bool editMap = true;
|
||||||
|
bool netToggle = false;
|
||||||
|
|
||||||
while (!WindowShouldClose())
|
float simSpeed = 1.0f;
|
||||||
{
|
int frameCounter = 0;
|
||||||
frameCounter++;
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) {
|
int guiScreenWidth = 720;
|
||||||
editMap = !editMap;
|
|
||||||
}
|
|
||||||
if (IsKeyPressed(KEY_N)) {
|
|
||||||
netToggle = !netToggle;
|
|
||||||
}
|
|
||||||
if (IsKeyPressed(KEY_EQUAL)) {
|
|
||||||
simSpeed *= 2.0f;
|
|
||||||
}
|
|
||||||
if (IsKeyPressed(KEY_MINUS)) {
|
|
||||||
simSpeed *= 0.5f;
|
|
||||||
}
|
|
||||||
if (IsKeyPressed(KEY_C)) {
|
|
||||||
ClearMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editMap)
|
Camera2D camera = {
|
||||||
{
|
.target = (Vector2){ screenWidth / 2.0f, screenHeight / 2.0f },
|
||||||
mousePos = GetMousePosition();
|
.offset = (Vector2){ screenWidth / 2.0f, screenHeight / 2.0f },
|
||||||
mouseCellX = (int)(Clamp(mousePos.x, 0, (float)(MAP_X * CELL_SIZE - 1)) / CELL_SIZE);
|
.rotation = 0.0f,
|
||||||
mouseCellY = (int)(Clamp(mousePos.y, 0, (float)(MAP_Y * CELL_SIZE - 1)) / CELL_SIZE);
|
.zoom = 1.0f
|
||||||
|
};
|
||||||
|
int cameraSpeed;
|
||||||
|
float frametime;
|
||||||
|
//float mouseWheel;
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
while (!WindowShouldClose())
|
||||||
map[mouseCellX][mouseCellY] = true;
|
{
|
||||||
}
|
frameCounter++;
|
||||||
else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) {
|
frametime = GetFrameTime();
|
||||||
map[mouseCellX][mouseCellY] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (FloatEquals(simSpeed, 1.0f)) {
|
|
||||||
celluralAutomata();
|
|
||||||
}
|
|
||||||
else if (simSpeed < 1.0f and frameCounter >= 1 / simSpeed) {
|
|
||||||
celluralAutomata();
|
|
||||||
//printf("%d %d\n", frameCounter, (int)(1 / simSpeed));
|
|
||||||
frameCounter = 0;
|
|
||||||
}
|
|
||||||
else if (simSpeed > 1.0f) {
|
|
||||||
for (int i = 0; i < (int)simSpeed; i++) {
|
|
||||||
celluralAutomata();
|
|
||||||
}
|
|
||||||
//printf("%f speed\n", simSpeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
BeginDrawing();
|
if (IsKeyPressed(KEY_SPACE)) {
|
||||||
ClearBackground(WHITE);
|
editMap = !editMap;
|
||||||
|
}
|
||||||
|
if (IsKeyPressed(KEY_N)) {
|
||||||
|
netToggle = !netToggle;
|
||||||
|
}
|
||||||
|
if (IsKeyPressed(KEY_EQUAL)) {
|
||||||
|
simSpeed *= 2.0f;
|
||||||
|
}
|
||||||
|
if (IsKeyPressed(KEY_MINUS)) {
|
||||||
|
simSpeed *= 0.5f;
|
||||||
|
}
|
||||||
|
if (IsKeyPressed(KEY_C)) {
|
||||||
|
ClearMap();
|
||||||
|
}
|
||||||
|
|
||||||
drawMap();
|
if (editMap)
|
||||||
drawBottomBar();
|
{
|
||||||
|
mousePos = GetMousePosition();
|
||||||
|
mouseWorldPos = GetScreenToWorld2D(mousePos, camera);
|
||||||
|
mouseWorldCellX = (int)(Clamp(mouseWorldPos.x, 0, (float)(MAP_X * CELL_SIZE - 1)) / CELL_SIZE);
|
||||||
|
mouseWorldCellY = (int)(Clamp(mouseWorldPos.y, 0, (float)(MAP_Y * CELL_SIZE - 1)) / CELL_SIZE);
|
||||||
|
|
||||||
if (netToggle) drawNet();
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||||
|
map[mouseWorldCellX][mouseWorldCellY] = true;
|
||||||
|
}
|
||||||
|
else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) {
|
||||||
|
map[mouseWorldCellX][mouseWorldCellY] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (FloatEquals(simSpeed, 1.0f)) {
|
||||||
|
//celluralAutomata();
|
||||||
|
gol_thread_start();
|
||||||
|
}
|
||||||
|
else if (simSpeed < 1.0f and frameCounter >= 1 / simSpeed) {
|
||||||
|
//celluralAutomata();
|
||||||
|
gol_thread_start();
|
||||||
|
frameCounter = 0;
|
||||||
|
}
|
||||||
|
else if (simSpeed > 1.0f) {
|
||||||
|
for (int i = 0; i < (int)simSpeed; i++) {
|
||||||
|
//celluralAutomata();
|
||||||
|
gol_thread_start();
|
||||||
|
}
|
||||||
|
//printf("%f speed\n", simSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
if (editMap)
|
|
||||||
{
|
|
||||||
Rectangle rec = { mouseCellX * FCELL_SIZE, mouseCellY * FCELL_SIZE, FCELL_SIZE, FCELL_SIZE };
|
|
||||||
DrawRectangleLinesEx(rec, 2, GREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Rectangle settingsBox = { 400, 400, 400, 200 };
|
|
||||||
//GuiGroupBox(settingsBox, u8"Init game");
|
|
||||||
//Rectangle valueBox1 = { 620, 420, 100, 40 };
|
|
||||||
//GuiValueBox(valueBox1, u8"screen Width ", &guyScreenWidth, 120, 2560, true);
|
|
||||||
|
|
||||||
DrawFPS(0, MAP_Y * CELL_SIZE);
|
if (IsKeyDown(KEY_LEFT_SHIFT)) {
|
||||||
DrawText(TextFormat("%.4fx", simSpeed), 0, MAP_Y * CELL_SIZE + 20, 20, ORANGE);
|
cameraSpeed = 1000;
|
||||||
DrawText(TextFormat("%.1f TPS", GetFPS() * simSpeed), 0, MAP_Y * CELL_SIZE + 40, 20, BLUE);
|
}
|
||||||
|
else {
|
||||||
|
cameraSpeed = 200;
|
||||||
|
}
|
||||||
|
|
||||||
EndDrawing();
|
if (IsKeyDown(KEY_W)) {
|
||||||
}
|
camera.target.y -= cameraSpeed * frametime;
|
||||||
|
}
|
||||||
|
if (IsKeyDown(KEY_S)) {
|
||||||
|
camera.target.y += cameraSpeed * frametime;
|
||||||
|
}
|
||||||
|
if (IsKeyDown(KEY_A)) {
|
||||||
|
camera.target.x -= cameraSpeed * frametime;
|
||||||
|
}
|
||||||
|
if (IsKeyDown(KEY_D)) {
|
||||||
|
camera.target.x += cameraSpeed * frametime;
|
||||||
|
}
|
||||||
|
|
||||||
for (int x = 0; x < MAP_X; x++) {
|
BeginDrawing();
|
||||||
free(map[x]);
|
|
||||||
free(tempMap[x]);
|
|
||||||
}
|
|
||||||
free(map);
|
|
||||||
free(tempMap);
|
|
||||||
|
|
||||||
UnloadFont(InconsolataBold);
|
ClearBackground(WHITE);
|
||||||
|
|
||||||
CloseWindow();
|
BeginMode2D(camera);
|
||||||
|
|
||||||
return 0;
|
drawMap();
|
||||||
|
Rectangle rec = { -2, -2, MAP_X * CELL_SIZE + 4, MAP_Y * CELL_SIZE + 4 };
|
||||||
|
|
||||||
|
DrawRectangleLinesEx(rec, 2.0f, RED);
|
||||||
|
|
||||||
|
if (netToggle) drawNet();
|
||||||
|
|
||||||
|
if (editMap)
|
||||||
|
{
|
||||||
|
Rectangle rec = { mouseWorldCellX * FCELL_SIZE, mouseWorldCellY * FCELL_SIZE, FCELL_SIZE, FCELL_SIZE };
|
||||||
|
DrawRectangleLinesEx(rec, 2, GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
EndMode2D();
|
||||||
|
|
||||||
|
drawBottomBar();
|
||||||
|
|
||||||
|
DrawFPS(0, MAP_Y * CELL_SIZE);
|
||||||
|
DrawText(TextFormat("%.4fx", simSpeed), 0, MAP_Y * CELL_SIZE + 20, 20, ORANGE);
|
||||||
|
DrawText(TextFormat("%.1f TPS", GetFPS() * simSpeed), 0, MAP_Y * CELL_SIZE + 40, 20, BLUE);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = 0; x < MAP_X; x++) {
|
||||||
|
free(map[x]);
|
||||||
|
free(tempMap[x]);
|
||||||
|
}
|
||||||
|
free(map);
|
||||||
|
free(tempMap);
|
||||||
|
|
||||||
|
//ArenaDestroy(&arena);
|
||||||
|
|
||||||
|
UnloadFont(InconsolataBold);
|
||||||
|
|
||||||
|
CloseWindow();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WinMain() {
|
int WinMain() {
|
||||||
return main();
|
return main();
|
||||||
}
|
}
|
64
Game of Life/src/memory_arena.c
Normal file
64
Game of Life/src/memory_arena.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "memory_arena.h"
|
||||||
|
|
||||||
|
static bool is_power_of_two(uintptr_t x) {
|
||||||
|
return (x & (x - 1)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uintptr_t AlignForward(uintptr_t ptr, size_t alignment) {
|
||||||
|
uintptr_t p, a, modulo;
|
||||||
|
|
||||||
|
assert(is_power_of_two(alignment));
|
||||||
|
|
||||||
|
p = ptr;
|
||||||
|
a = (uintptr_t)alignment;
|
||||||
|
// Same as (p % a) but faster as 'a' is a power of two
|
||||||
|
modulo = p & (a - 1);
|
||||||
|
|
||||||
|
if (modulo != 0) {
|
||||||
|
// If 'p' address is not aligned, push the address to the
|
||||||
|
// next value which is aligned
|
||||||
|
p += a - modulo;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ArenaAllocAligned(Arena* arena, size_t size, size_t alignment)
|
||||||
|
{
|
||||||
|
uintptr_t aligned_offset_ptr = AlignForward(arena->offset_ptr, alignment);
|
||||||
|
uintptr_t next_offset_ptr = aligned_offset_ptr + size;
|
||||||
|
|
||||||
|
if (next_offset_ptr - (uintptr_t)arena->buffer <= arena->size)
|
||||||
|
{
|
||||||
|
arena->offset_ptr = next_offset_ptr;
|
||||||
|
return (void*)aligned_offset_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "\nError in ArenaAllocAligned: reached arena end.\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ArenaAlloc(Arena* arena, size_t size)
|
||||||
|
{
|
||||||
|
return ArenaAllocAligned(arena, size, DEFAULT_ALIGNMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
Arena ArenaCreate(void* buffer, size_t buffer_size)
|
||||||
|
{
|
||||||
|
return (Arena) {
|
||||||
|
.buffer = buffer,
|
||||||
|
.size = buffer_size,
|
||||||
|
.offset_ptr = (uintptr_t)buffer
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaDestroy(Arena* arena)
|
||||||
|
{
|
||||||
|
free(arena->buffer);
|
||||||
|
arena->offset_ptr = 0;
|
||||||
|
arena->size = 0;
|
||||||
|
}
|
21
Game of Life/src/memory_arena.h
Normal file
21
Game of Life/src/memory_arena.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#define ARENA_ALIGNMENT(type) offsetof(struct { char c; type x; }, x) // generates C4116 warning
|
||||||
|
|
||||||
|
#ifndef DEFAULT_ALIGNMENT
|
||||||
|
#define DEFAULT_ALIGNMENT (2 * sizeof(void*))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void* buffer;
|
||||||
|
size_t size;
|
||||||
|
uintptr_t offset_ptr;
|
||||||
|
} Arena;
|
||||||
|
|
||||||
|
Arena ArenaCreate(void* buffer, size_t buffer_size);
|
||||||
|
void* ArenaAlloc(Arena* arena, size_t size);
|
||||||
|
void* ArenaAllocAligned(Arena* arena, size_t size, size_t alignment);
|
||||||
|
void ArenaDestroy(Arena* arena);
|
@ -1,463 +0,0 @@
|
|||||||
#include "parallel_for.h"
|
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(__linux__)
|
|
||||||
#define POSIX
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "Platform not supported."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#else
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* A task descriptor specifying the input element and the address at which the *
|
|
||||||
* output element should be stored. *
|
|
||||||
******************************************************************************/
|
|
||||||
typedef struct task_descriptor {
|
|
||||||
void* input_element;
|
|
||||||
void** output_element_address;
|
|
||||||
} task_descriptor;
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* This structure implements a concurrent array-based queue. *
|
|
||||||
************************************************************/
|
|
||||||
typedef struct concurrent_queue {
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
pthread_mutex_t mutex;
|
|
||||||
#elif defined(_WIN32)
|
|
||||||
CRITICAL_SECTION criticalSection;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
task_descriptor** array;
|
|
||||||
size_t begin_index;
|
|
||||||
size_t end_index;
|
|
||||||
size_t size;
|
|
||||||
size_t len;
|
|
||||||
} concurrent_queue;
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* Initializes the input concurrent queue to an empty state. *
|
|
||||||
************************************************************/
|
|
||||||
static int concurrent_queue_init(concurrent_queue* queue, size_t len)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
queue->array = malloc(len * sizeof(*queue->array));
|
|
||||||
|
|
||||||
if (queue->array == NULL)
|
|
||||||
{
|
|
||||||
return ERROR_FORP_MALLOC_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
queue->begin_index = 0;
|
|
||||||
queue->end_index = 0;
|
|
||||||
queue->size = 0;
|
|
||||||
queue->len = len;
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
|
|
||||||
ret = pthread_mutex_init(&queue->mutex, NULL);
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
{
|
|
||||||
return ERROR_FORP_NO_MUTEX_INIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
InitializeCriticalSection(&queue->criticalSection);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ERROR_FORP_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************
|
|
||||||
* Appends a task descriptor to the tail of the queue. *
|
|
||||||
******************************************************/
|
|
||||||
static void concurrent_queue_enqueue(concurrent_queue* queue,
|
|
||||||
task_descriptor* descriptor)
|
|
||||||
{
|
|
||||||
queue->array[queue->end_index] = descriptor;
|
|
||||||
queue->end_index++;
|
|
||||||
queue->size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Removes the head element from the queue. Unlike all other functions related *
|
|
||||||
* to the queue, this is one is thread-safe. *
|
|
||||||
******************************************************************************/
|
|
||||||
static task_descriptor* concurrent_queue_dequeue(concurrent_queue* queue)
|
|
||||||
{
|
|
||||||
task_descriptor* descriptor;
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
pthread_mutex_lock(&queue->mutex);
|
|
||||||
#else
|
|
||||||
EnterCriticalSection(&queue->criticalSection);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (queue->size > 0)
|
|
||||||
{
|
|
||||||
descriptor = queue->array[queue->begin_index];
|
|
||||||
queue->begin_index++;
|
|
||||||
queue->size--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
descriptor = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
pthread_mutex_unlock(&queue->mutex);
|
|
||||||
#else
|
|
||||||
LeaveCriticalSection(&queue->criticalSection);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return descriptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Releases all the resources occupied by the queue, or namely, the mutex and *
|
|
||||||
* the array. *
|
|
||||||
*****************************************************************************/
|
|
||||||
static int concurrent_queue_destroy(concurrent_queue* queue)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < queue->len; i++)
|
|
||||||
{
|
|
||||||
free(queue->array[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(queue->array);
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
ret = pthread_mutex_destroy(&queue->mutex);
|
|
||||||
return ret == 0 ? ERROR_FORP_SUCCESS : ERROR_FORP_NO_MUTEX_DESTROY;
|
|
||||||
#else
|
|
||||||
DeleteCriticalSection(&queue->criticalSection);
|
|
||||||
return ERROR_FORP_SUCCESS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************
|
|
||||||
* Returns the number of processors on Mac OS or Linux. *
|
|
||||||
*******************************************************/
|
|
||||||
static int get_number_of_processors_apple_linux(size_t* p_number_of_processors)
|
|
||||||
{
|
|
||||||
#ifdef POSIX
|
|
||||||
* p_number_of_processors = (size_t)sysconf(_SC_NPROCESSORS_ONLN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ERROR_FORP_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************
|
|
||||||
* Returns the number of processors on Windows. *
|
|
||||||
***********************************************/
|
|
||||||
static int get_number_of_processors_windows(size_t* p_number_of_processors)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
SYSTEM_INFO si;
|
|
||||||
GetSystemInfo(&si);
|
|
||||||
*p_number_of_processors = (size_t)2 * si.dwNumberOfProcessors;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ERROR_FORP_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************
|
|
||||||
* A portable function for returning the number of processors. *
|
|
||||||
**************************************************************/
|
|
||||||
static int get_number_of_processors(size_t* p_number_of_processors)
|
|
||||||
{
|
|
||||||
#ifdef POSIX
|
|
||||||
return get_number_of_processors_apple_linux(p_number_of_processors);
|
|
||||||
#else
|
|
||||||
return get_number_of_processors_windows(p_number_of_processors);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Specifies the worker thread arguments. Holds the queue and the function to *
|
|
||||||
* be applied to each queue element. *
|
|
||||||
*****************************************************************************/
|
|
||||||
typedef struct worker_thread_proc_args {
|
|
||||||
concurrent_queue* queue;
|
|
||||||
void* (*func)(void*);
|
|
||||||
int return_status;
|
|
||||||
} worker_thread_proc_args;
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Implements the worker threads. *
|
|
||||||
*********************************/
|
|
||||||
static void* worker_thread_proc(void* args)
|
|
||||||
{
|
|
||||||
worker_thread_proc_args* worker_thread_proc_arguments =
|
|
||||||
(worker_thread_proc_args*)args;
|
|
||||||
|
|
||||||
concurrent_queue* queue = worker_thread_proc_arguments->queue;
|
|
||||||
void* (*func)(void*) = worker_thread_proc_arguments->func;
|
|
||||||
task_descriptor* task_desc;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
{
|
|
||||||
worker_thread_proc_arguments->return_status = ret;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
worker_thread_proc_arguments->return_status = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((task_desc = concurrent_queue_dequeue(queue)) != NULL)
|
|
||||||
{
|
|
||||||
*task_desc->output_element_address = func(task_desc->input_element);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************
|
|
||||||
* Cancels all the first 'len' threads. *
|
|
||||||
***************************************/
|
|
||||||
#ifdef POSIX
|
|
||||||
static void cancel_threads(pthread_t* pthreads, size_t len)
|
|
||||||
#else
|
|
||||||
static void cancel_threads(HANDLE* threads, size_t len)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
pthread_cancel(pthreads[i]);
|
|
||||||
#else
|
|
||||||
TerminateThread(threads[i], 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* The actual implementation of the parallel for construct. *
|
|
||||||
***********************************************************/
|
|
||||||
int forp(void** input, void** output, size_t len, void* (*func)(void*))
|
|
||||||
{
|
|
||||||
size_t number_of_cores;
|
|
||||||
size_t szi;
|
|
||||||
int ret;
|
|
||||||
int join_ret = ERROR_FORP_SUCCESS;
|
|
||||||
concurrent_queue queue;
|
|
||||||
task_descriptor* task_desc;
|
|
||||||
worker_thread_proc_args* wtpa;
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
|
|
||||||
pthread_t* threads;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
HANDLE* threads;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (input == NULL || output == NULL || func == NULL)
|
|
||||||
{
|
|
||||||
return ERROR_FORP_NO_ARGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
{
|
|
||||||
/*****************
|
|
||||||
* Nothing to do. *
|
|
||||||
*****************/
|
|
||||||
return ERROR_FORP_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = get_number_of_processors(&number_of_cores);
|
|
||||||
|
|
||||||
if (ret != ERROR_FORP_SUCCESS)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (number_of_cores == 0)
|
|
||||||
{
|
|
||||||
return ERROR_FORP_UNKNOWN_CORES;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ret = concurrent_queue_init(&queue, len)) != ERROR_FORP_SUCCESS)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************
|
|
||||||
* Create a concurrent queue of tasks. *
|
|
||||||
**************************************/
|
|
||||||
for (szi = 0; szi < len; szi++)
|
|
||||||
{
|
|
||||||
task_desc = malloc(sizeof * task_desc);
|
|
||||||
|
|
||||||
if (task_desc == NULL)
|
|
||||||
{
|
|
||||||
concurrent_queue_destroy(&queue);
|
|
||||||
return ERROR_FORP_MALLOC_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
task_desc->input_element = input[szi];
|
|
||||||
task_desc->output_element_address = &output[szi];
|
|
||||||
concurrent_queue_enqueue(&queue, task_desc);
|
|
||||||
|
|
||||||
if (ret != ERROR_FORP_SUCCESS)
|
|
||||||
{
|
|
||||||
concurrent_queue_destroy(&queue);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************
|
|
||||||
* Create the worker threads. *
|
|
||||||
*****************************/
|
|
||||||
threads = malloc(number_of_cores * sizeof(*threads));
|
|
||||||
|
|
||||||
if (threads == NULL)
|
|
||||||
{
|
|
||||||
concurrent_queue_destroy(&queue);
|
|
||||||
return ERROR_FORP_MALLOC_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wtpa = malloc(number_of_cores * sizeof(*wtpa));
|
|
||||||
|
|
||||||
if (wtpa == NULL)
|
|
||||||
{
|
|
||||||
free(threads);
|
|
||||||
concurrent_queue_destroy(&queue);
|
|
||||||
return ERROR_FORP_MALLOC_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (szi = 0; szi < number_of_cores; szi++)
|
|
||||||
{
|
|
||||||
wtpa[szi].queue = &queue;
|
|
||||||
wtpa[szi].func = func;
|
|
||||||
wtpa[szi].return_status = 0;
|
|
||||||
|
|
||||||
#ifdef POSIX
|
|
||||||
ret = pthread_create(&threads[szi],
|
|
||||||
NULL,
|
|
||||||
worker_thread_proc,
|
|
||||||
&wtpa[szi]);
|
|
||||||
#else
|
|
||||||
threads[szi] = CreateThread(NULL,
|
|
||||||
100000,
|
|
||||||
(LPTHREAD_START_ROUTINE)worker_thread_proc,
|
|
||||||
(LPVOID)&wtpa[szi],
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
{
|
|
||||||
cancel_threads(threads, szi);
|
|
||||||
concurrent_queue_destroy(&queue);
|
|
||||||
return ERROR_FORP_NO_THREAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wtpa[szi].return_status != 0)
|
|
||||||
{
|
|
||||||
cancel_threads(threads, szi + 1);
|
|
||||||
concurrent_queue_destroy(&queue);
|
|
||||||
return ERROR_FORP_NO_SETCANCELTYPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************
|
|
||||||
* Wait for all the worker threads to complete. *
|
|
||||||
***********************************************/
|
|
||||||
for (szi = 0; szi < number_of_cores; szi++)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
if (WaitForSingleObject(threads[szi], INFINITE) != 0 && join_ret == 0)
|
|
||||||
{
|
|
||||||
join_ret = ERROR_FORP_NO_JOIN;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
join_ret = pthread_join(threads[szi], NULL);
|
|
||||||
|
|
||||||
if (ret != 0 && join_ret == ERROR_FORP_SUCCESS)
|
|
||||||
{
|
|
||||||
join_ret = ERROR_FORP_NO_JOIN;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return join_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* forp_error(int error_code)
|
|
||||||
{
|
|
||||||
switch (error_code)
|
|
||||||
{
|
|
||||||
case ERROR_FORP_SUCCESS:
|
|
||||||
return "forp succeeded.";
|
|
||||||
|
|
||||||
case ERROR_FORP_NO_ARGS:
|
|
||||||
return "Some arguments missing.";
|
|
||||||
|
|
||||||
case ERROR_FORP_NO_JOIN:
|
|
||||||
return "Could not join a thread.";
|
|
||||||
|
|
||||||
case ERROR_FORP_CPU_FEOF:
|
|
||||||
return "Reached EOF while reading the number of processors.";
|
|
||||||
|
|
||||||
case ERROR_FORP_NO_THREAD:
|
|
||||||
return "Could create a thread.";
|
|
||||||
|
|
||||||
case ERROR_FORP_CPU_FERROR:
|
|
||||||
return "An error occured while reading the number of processors.";
|
|
||||||
|
|
||||||
case ERROR_FORP_POPEN_FAIL:
|
|
||||||
return "Could not execute a program in popen.";
|
|
||||||
|
|
||||||
case ERROR_FORP_MALLOC_FAIL:
|
|
||||||
return "A call to malloc returned NULL.";
|
|
||||||
|
|
||||||
case ERROR_FORP_SSCANF_FAIL:
|
|
||||||
return "sscanf failed.";
|
|
||||||
|
|
||||||
case ERROR_FORP_NO_MUTEX_INIT:
|
|
||||||
return "Could not initialize a mutex.";
|
|
||||||
|
|
||||||
case ERROR_FORP_NO_MUTEX_DESTROY:
|
|
||||||
return "Could not destroy a mutex.";
|
|
||||||
|
|
||||||
case ERROR_FORP_UNKNOWN_CORES:
|
|
||||||
return "Could not determine the number of processors.";
|
|
||||||
|
|
||||||
case ERROR_FORP_NO_SETCANCELTYPE:
|
|
||||||
return "setcanceltype failed.";
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "Unknown error code.";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
#ifndef PARALLEL_FOR_H
|
|
||||||
#define PARALLEL_FOR_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define ERROR_FORP_SUCCESS 0
|
|
||||||
#define ERROR_FORP_NO_ARGS 1
|
|
||||||
#define ERROR_FORP_UNKNOWN_CORES 2
|
|
||||||
#define ERROR_FORP_NO_MUTEX_INIT 3
|
|
||||||
#define ERROR_FORP_NO_MUTEX_DESTROY 4
|
|
||||||
#define ERROR_FORP_MALLOC_FAIL 5
|
|
||||||
#define ERROR_FORP_SSCANF_FAIL 6
|
|
||||||
#define ERROR_FORP_POPEN_FAIL 7
|
|
||||||
#define ERROR_FORP_CPU_FEOF 8
|
|
||||||
#define ERROR_FORP_CPU_FERROR 9
|
|
||||||
#define ERROR_FORP_NO_THREAD 10
|
|
||||||
#define ERROR_FORP_NO_SETCANCELTYPE 11
|
|
||||||
#define ERROR_FORP_NO_JOIN 12
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Runs a multithreaded for loop over the input array producing the results and *
|
|
||||||
* storing them in the output array. *
|
|
||||||
*******************************************************************************/
|
|
||||||
int forp(void** input,
|
|
||||||
void** output,
|
|
||||||
size_t len,
|
|
||||||
void* (*func)(void*));
|
|
||||||
|
|
||||||
/*************************************************************************
|
|
||||||
* Returns a human-readable description of an error code related to forp. *
|
|
||||||
*************************************************************************/
|
|
||||||
const char* forp_error(int error_code);
|
|
||||||
|
|
||||||
#endif /* PARALLEL_FOR_H */
|
|
BIN
Iso_C_1999_definition.pdf
Normal file
BIN
Iso_C_1999_definition.pdf
Normal file
Binary file not shown.
28
exam test variant/exam test variant.sln
Normal file
28
exam test variant/exam test variant.sln
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.12.35527.113 d17.12
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "exam test variant", "exam test variant\exam test variant.vcxproj", "{4BD82D12-E491-4ACC-9A31-E269F2A6F346}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Release|x64.Build.0 = Release|x64
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{4BD82D12-E491-4ACC-9A31-E269F2A6F346}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
135
exam test variant/exam test variant/exam test variant.vcxproj
Normal file
135
exam test variant/exam test variant/exam test variant.vcxproj
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>17.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{4bd82d12-e491-4acc-9a31-e269f2a6f346}</ProjectGuid>
|
||||||
|
<RootNamespace>examtestvariant</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Исходные файлы">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы заголовков">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Файлы ресурсов">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
199
exam test variant/exam test variant/main.c
Normal file
199
exam test variant/exam test variant/main.c
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int N1;
|
||||||
|
int N2;
|
||||||
|
int M2;
|
||||||
|
|
||||||
|
#define MAX_N2 20
|
||||||
|
#define MAX_M2 20
|
||||||
|
|
||||||
|
int A1[20];
|
||||||
|
int A2[MAX_N2][MAX_M2];
|
||||||
|
|
||||||
|
void loadLists(char filepath[])
|
||||||
|
{
|
||||||
|
FILE* fin = fopen(filepath, "r");
|
||||||
|
|
||||||
|
if (fin == NULL) {
|
||||||
|
printf("File didn't open!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fscanf(fin, "%d", &N1);
|
||||||
|
|
||||||
|
for (int i = 0; i < N1; i++) {
|
||||||
|
fscanf(fin, "%d", &A1[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fscanf(fin, "%d", &N2);
|
||||||
|
fscanf(fin, "%d", &M2);
|
||||||
|
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
fscanf(fin, "%d", &A2[n][m]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveLists(char filepath[])
|
||||||
|
{
|
||||||
|
FILE* fout = fopen(filepath, "w");
|
||||||
|
if (fopen == NULL) {
|
||||||
|
printf("File didn't create!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fout, "%d\n", N1);
|
||||||
|
for (int i = 0; i < N1; i++) {
|
||||||
|
fprintf(fout, "%d ", A1[i]);
|
||||||
|
}
|
||||||
|
fprintf(fout, "\n");
|
||||||
|
|
||||||
|
fprintf(fout, "%d %d\n", N2, M2);
|
||||||
|
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
fprintf(fout, "%d ", A2[n][m]);
|
||||||
|
}
|
||||||
|
fprintf(fout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void printLists()
|
||||||
|
{
|
||||||
|
printf("===== Òåêóùåå ñîñòîÿíèå ìàññèâîâ =====\n");
|
||||||
|
printf("A1[%d]: ", N1);
|
||||||
|
for (int i = 0; i < N1; i++) {
|
||||||
|
printf("%d ", A1[i]);
|
||||||
|
}
|
||||||
|
printf("\n\n");
|
||||||
|
|
||||||
|
printf("A2[%d][%d]:\n", N2, M2);
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
printf("%2d ", A2[n][m]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
printf("=====================================\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void task2()
|
||||||
|
{
|
||||||
|
int firstEvenId = 0;
|
||||||
|
int lastEvenId = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < N1; i++) {
|
||||||
|
if (A1[i] % 2 == 0) {
|
||||||
|
firstEvenId = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < N1; i++) {
|
||||||
|
if (A1[i] % 2 == 0) {
|
||||||
|
lastEvenId = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = firstEvenId + 1; i < lastEvenId; i++) {
|
||||||
|
if (A1[i] % 2 == 0) {
|
||||||
|
A1[i] += 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("> Âûïîëíåíî çàäàíèå 2\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void deleteRow(int row)
|
||||||
|
{
|
||||||
|
for (int n = row; n < N2 - 1; n++) {
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
A2[n][m] = A2[n + 1][m];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
N2 -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void addColumn() {
|
||||||
|
if (M2 + 1 <= MAX_M2) {
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
A2[n][M2] = 0;
|
||||||
|
}
|
||||||
|
M2++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Äîñòèãíóò ìàêñèìóì êîëîíîê!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void insertColumn(int column) {
|
||||||
|
if (M2 + 1 <= MAX_M2) {
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
for (int m = M2; m > column; m--) {
|
||||||
|
A2[n][m] = A2[n][m - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
A2[n][column] = 0;
|
||||||
|
}
|
||||||
|
M2++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Äîñòèãíóò ìàêñèìóì êîëîíîê!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void insertRow(int row) {
|
||||||
|
if (N2 + 1 <= MAX_N2) {
|
||||||
|
for (int n = N2; n > row; n--) {
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
A2[n][m] = A2[n - 1][m];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
A2[row][m] = 0;
|
||||||
|
}
|
||||||
|
N2++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("Äîñòèãíóò ìàêñèìóì ñòðîê!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void task3() {
|
||||||
|
for (int n = 0; n < N2; n++) {
|
||||||
|
for (int m = 0; m < M2; m++) {
|
||||||
|
if (A2[n][m] < 0) {
|
||||||
|
deleteRow(n);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("> Âûïîëíåíî çàäàíèå 3\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
SetConsoleCP(1251);
|
||||||
|
SetConsoleOutputCP(1251);
|
||||||
|
|
||||||
|
loadLists("test.txt");
|
||||||
|
printLists();
|
||||||
|
|
||||||
|
task2();
|
||||||
|
task3();
|
||||||
|
|
||||||
|
printLists();
|
||||||
|
|
||||||
|
saveLists("out.txt");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
5
exam test variant/exam test variant/out.txt
Normal file
5
exam test variant/exam test variant/out.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
6
|
||||||
|
1 2 104 106 7 8
|
||||||
|
2 4
|
||||||
|
-2 -1 0 1
|
||||||
|
2 3 4 3
|
6
exam test variant/exam test variant/test.txt
Normal file
6
exam test variant/exam test variant/test.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
6
|
||||||
|
1 2 4 6 7 8
|
||||||
|
3 4
|
||||||
|
-2 -1 0 1
|
||||||
|
2 3 4 3
|
||||||
|
2 1 0 -1
|
@ -1,324 +1,324 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#define MAX_M 10
|
#define MAX_M 10
|
||||||
#define MAX_N 10
|
#define MAX_N 10
|
||||||
|
|
||||||
int m = 3;
|
int m = 3;
|
||||||
int n = 3;
|
int n = 3;
|
||||||
|
|
||||||
int arr[MAX_M][MAX_N] = {
|
int arr[MAX_M][MAX_N] = {
|
||||||
{1, 2, 3},
|
{1, 2, 3},
|
||||||
{4, 5, 6},
|
{4, 5, 6},
|
||||||
{7, 8, 9}
|
{7, 8, 9}
|
||||||
};
|
};
|
||||||
|
|
||||||
void printarr() {
|
void printarr() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
printf("%2d ", arr[i][j]);
|
printf("%2d ", arr[i][j]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_with_indexes() {
|
void fill_with_indexes() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[i][j] = (i * 10) + j;
|
arr[i][j] = (i * 10) + j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillZero() {
|
void fillZero() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[i][j] = 0;
|
arr[i][j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillRand() {
|
void fillRand() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[i][j] = rand() % 10;
|
arr[i][j] = rand() % 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void findMin() {
|
void findMin() {
|
||||||
int min = arr[0][0];
|
int min = arr[0][0];
|
||||||
int iMin = 0;
|
int iMin = 0;
|
||||||
int jMin = 0;
|
int jMin = 0;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
for (int j = 0; j < m; j++) {
|
for (int j = 0; j < m; j++) {
|
||||||
if (arr[i][j] < min) {
|
if (arr[i][j] < min) {
|
||||||
printf("min = %d\n", arr[i][j]);
|
printf("min = %d\n", arr[i][j]);
|
||||||
printf("imin = %d\n", i);
|
printf("imin = %d\n", i);
|
||||||
printf("jmin = %d\n", j);
|
printf("jmin = %d\n", j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteRow(int row) {
|
void deleteRow(int row) {
|
||||||
for (int i = row; i < m - 1; i++) {
|
for (int i = row; i < m - 1; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[i][j] = arr[i + 1][j];
|
arr[i][j] = arr[i + 1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m--;
|
m--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addColumn() {
|
void addColumn() {
|
||||||
if (n + 1 <= MAX_N) {
|
if (n + 1 <= MAX_N) {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
arr[i][n] = 0;
|
arr[i][n] = 0;
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Достигнут максимум колонок!\n");
|
printf("Достигнут максимум колонок!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertColumn(int column) {
|
void insertColumn(int column) {
|
||||||
if (n + 1 <= MAX_N) {
|
if (n + 1 <= MAX_N) {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = n; j > column; j--) {
|
for (int j = n; j > column; j--) {
|
||||||
arr[i][j] = arr[i][j - 1];
|
arr[i][j] = arr[i][j - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
arr[i][column] = 0;
|
arr[i][column] = 0;
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Достигнут максимум колонок!\n");
|
printf("Достигнут максимум колонок!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertRow(int row) {
|
void insertRow(int row) {
|
||||||
if (m + 1 <= MAX_M) {
|
if (m + 1 <= MAX_M) {
|
||||||
for (int i = m; i > row; i--) {
|
for (int i = m; i > row; i--) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[i][j] = arr[i - 1][j];
|
arr[i][j] = arr[i - 1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
arr[row][i] = 0;
|
arr[row][i] = 0;
|
||||||
}
|
}
|
||||||
m++;
|
m++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Достигнут максимум строк!\n");
|
printf("Достигнут максимум строк!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void odd10x() {
|
void odd10x() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
if (arr[i][j] % 2 != 0) arr[i][j] *= 10;
|
if (arr[i][j] % 2 != 0) arr[i][j] *= 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void crat10() {
|
void crat10() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
if (arr[i][j] % 10 == 0) arr[i][j] /= 10;
|
if (arr[i][j] % 10 == 0) arr[i][j] /= 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputArr() {
|
void inputArr() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
printf("a%d%d = ", i, j);
|
printf("a%d%d = ", i, j);
|
||||||
scanf_s("%d", &arr[i][j]);
|
scanf_s("%d", &arr[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void save() {
|
void save() {
|
||||||
FILE* fout = fopen("savefile.txt", "w");
|
FILE* fout = fopen("savefile.txt", "w");
|
||||||
if (fout == NULL) {
|
if (fout == NULL) {
|
||||||
puts("Невозможно открыть файл");
|
puts("Невозможно открыть файл");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "%d %d\n", m, n);
|
fprintf(fout, "%d %d\n", m, n);
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
fprintf(fout, "%2d ", arr[i][j]);
|
fprintf(fout, "%2d ", arr[i][j]);
|
||||||
}
|
}
|
||||||
fprintf(fout, "\n");
|
fprintf(fout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
FILE* fin = fopen("savefile.txt", "r");
|
FILE* fin = fopen("savefile.txt", "r");
|
||||||
if (fin == NULL) {
|
if (fin == NULL) {
|
||||||
puts("Невозможно открыть файл");
|
puts("Невозможно открыть файл");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf_s(fin, "%d%d", &m, &n);
|
fscanf_s(fin, "%d%d", &m, &n);
|
||||||
if (m > MAX_M || n > MAX_N) {
|
if (m > MAX_M || n > MAX_N) {
|
||||||
printf("Слишком большой массив в файле!");
|
printf("Слишком большой массив в файле!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
fscanf_s(fin, "%d", &arr[i][j]);
|
fscanf_s(fin, "%d", &arr[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fin);
|
fclose(fin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateColumn(int column) {
|
void duplicateColumn(int column) {
|
||||||
insertColumn(column);
|
insertColumn(column);
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
arr[i][column] = arr[i][column + 1];
|
arr[i][column] = arr[i][column + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int count(int num, int arr[], int len) {
|
int count(int num, int arr[], int len) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
if (arr[i] == num) count += 1;
|
if (arr[i] == num) count += 1;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void row0() {
|
void row0() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
if (count(0, arr[i], n) > 2) {
|
if (count(0, arr[i], n) > 2) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[i][j] = 0;
|
arr[i][j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateRow(int row) {
|
void duplicateRow(int row) {
|
||||||
insertRow(row);
|
insertRow(row);
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
arr[row][j] = arr[row + 1][j];
|
arr[row][j] = arr[row + 1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dupRow0() {
|
void dupRow0() {
|
||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
if (count(0, arr[i], n) > 0) {
|
if (count(0, arr[i], n) > 0) {
|
||||||
duplicateRow(i);
|
duplicateRow(i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
SetConsoleCP(1251);
|
SetConsoleCP(1251);
|
||||||
SetConsoleOutputCP(1251);
|
SetConsoleOutputCP(1251);
|
||||||
|
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
do {
|
do {
|
||||||
puts("\n");
|
puts("\n");
|
||||||
printf("Содержимое массива:\n");
|
printf("Содержимое массива:\n");
|
||||||
printarr(arr);
|
printarr(arr);
|
||||||
puts("Выберите программу");
|
puts("Выберите программу");
|
||||||
puts("1) Заполнение значениями i * 10 + j");
|
puts("1) Заполнение значениями i * 10 + j");
|
||||||
puts("2) Заполнение нулями");
|
puts("2) Заполнение нулями");
|
||||||
puts("3) Заполнение случайными числами от 0 до 9");
|
puts("3) Заполнение случайными числами от 0 до 9");
|
||||||
puts("4) Найти минимальный элемент");
|
puts("4) Найти минимальный элемент");
|
||||||
puts("5) Удалить строку");
|
puts("5) Удалить строку");
|
||||||
puts("6) Добавить пустую колонку");
|
puts("6) Добавить пустую колонку");
|
||||||
puts("7) Все нечетные увеличить в 10 раз");
|
puts("7) Все нечетные увеличить в 10 раз");
|
||||||
puts("8) Все кратные 10 уменьшить в 10 раз");
|
puts("8) Все кратные 10 уменьшить в 10 раз");
|
||||||
puts("9) Ввести массив с клавиатуры");
|
puts("9) Ввести массив с клавиатуры");
|
||||||
puts("10) Сохранить в файл");
|
puts("10) Сохранить в файл");
|
||||||
puts("11) Загрузить из файла");
|
puts("11) Загрузить из файла");
|
||||||
puts("12) Вставить пустую колонку");
|
puts("12) Вставить пустую колонку");
|
||||||
puts("13) Продублировать заданный столбец массива");
|
puts("13) Продублировать заданный столбец массива");
|
||||||
puts("14) Обнулить элементы тех строк, в которых встречается более двух нулевых элементов");
|
puts("14) Обнулить элементы тех строк, в которых встречается более двух нулевых элементов");
|
||||||
puts("15) Продублировать те строки, в которых встречаются нулевые элементы");
|
puts("15) Продублировать те строки, в которых встречаются нулевые элементы");
|
||||||
puts("");
|
puts("");
|
||||||
puts("0) Выйти из программы");
|
puts("0) Выйти из программы");
|
||||||
|
|
||||||
while (scanf_s(" %d", &n) != 1) {
|
while (scanf_s(" %d", &n) != 1) {
|
||||||
scanf_s("%*[^\n]");
|
scanf_s("%*[^\n]");
|
||||||
scanf_s("%*c");
|
scanf_s("%*c");
|
||||||
}
|
}
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
switch (n)
|
switch (n)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
fill_with_indexes();
|
fill_with_indexes();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fillZero();
|
fillZero();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fillRand();
|
fillRand();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
findMin();
|
findMin();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
printf("Какую строку удалить: ");
|
printf("Какую строку удалить: ");
|
||||||
scanf_s("%d", &tmp);
|
scanf_s("%d", &tmp);
|
||||||
deleteRow(tmp);
|
deleteRow(tmp);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
addColumn();
|
addColumn();
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
odd10x();
|
odd10x();
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
crat10();
|
crat10();
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
inputArr();
|
inputArr();
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
save();
|
save();
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
load();
|
load();
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
printf("На каком индексе вставить колонку: ");
|
printf("На каком индексе вставить колонку: ");
|
||||||
scanf_s("%d", &tmp);
|
scanf_s("%d", &tmp);
|
||||||
insertColumn(tmp);
|
insertColumn(tmp);
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
printf("На каком индексе одублировать столбец: ");
|
printf("На каком индексе одублировать столбец: ");
|
||||||
scanf_s("%d", &tmp);
|
scanf_s("%d", &tmp);
|
||||||
duplicateColumn(tmp);
|
duplicateColumn(tmp);
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
row0();
|
row0();
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
dupRow0();
|
dupRow0();
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
puts("Досвидания :3");
|
puts("Досвидания :3");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
puts("Ошибка: неправильное N");
|
puts("Ошибка: неправильное N");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (n != 0);
|
} while (n != 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>raylib.lib;opengl32.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>raylib33test.lib;opengl32.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@ -129,7 +129,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>raylib.lib;opengl32.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>raylib33test.lib;opengl32.lib;winmm.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
BIN
lab16 with raylib/lib/raylib33test.lib
Normal file
BIN
lab16 with raylib/lib/raylib33test.lib
Normal file
Binary file not shown.
@ -57,7 +57,7 @@ void* ArenaAlloc(Arena* arena, size_t size)
|
|||||||
return ArenaAllocAligned(arena, size, DEFAULT_ALIGNMENT);
|
return ArenaAllocAligned(arena, size, DEFAULT_ALIGNMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arena ArenaInit(size_t buffer_size)
|
Arena ArenaCreate(size_t buffer_size)
|
||||||
{
|
{
|
||||||
void* buffer = SafeMalloc(buffer_size);
|
void* buffer = SafeMalloc(buffer_size);
|
||||||
return (Arena) {
|
return (Arena) {
|
||||||
|
@ -15,7 +15,7 @@ typedef struct {
|
|||||||
uintptr_t offset_ptr;
|
uintptr_t offset_ptr;
|
||||||
} Arena;
|
} Arena;
|
||||||
|
|
||||||
Arena ArenaInit(size_t buffer_size);
|
Arena ArenaCreate(size_t buffer_size);
|
||||||
void* ArenaAlloc(Arena* arena, size_t size);
|
void* ArenaAlloc(Arena* arena, size_t size);
|
||||||
void* ArenaAllocAligned(Arena* arena, size_t size, size_t alignment);
|
void* ArenaAllocAligned(Arena* arena, size_t size, size_t alignment);
|
||||||
void ArenaDestroy(Arena* arena);
|
void ArenaDestroy(Arena* arena);
|
@ -1,15 +1,37 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <threads.h>
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
void thrd_func(int* i) {
|
#include <iso646.h>
|
||||||
printf_s("%d\n", *i);
|
#include <string.h>
|
||||||
}
|
|
||||||
|
#include <threads.h>
|
||||||
int main() {
|
|
||||||
thrd_t* threads[10];
|
int thrd_func(void* i) {
|
||||||
for (int i = 0; i < 10; i++) {
|
int* arg_ptr = (int*)i;
|
||||||
thrd_create(threads[i], thrd_func, &i);
|
|
||||||
}
|
unsigned long long y = 1;
|
||||||
return 0;
|
for (unsigned long long x = 0; x < 1000ULL * 1000 * 1000 * 10; x++) {
|
||||||
|
y += x;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("lol %d) y=%llu\n", *arg_ptr, y);
|
||||||
|
return *arg_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
thrd_t threads[10];
|
||||||
|
int args[10];
|
||||||
|
int results[10];
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
args[i] = i;
|
||||||
|
thrd_create(&threads[i], thrd_func, &args[i]);
|
||||||
|
printf("%d) thread created\n", i);
|
||||||
|
}
|
||||||
|
printf("-----------\n");
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
thrd_join(threads[i], &results[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
@ -1,135 +1,137 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|x64">
|
<ProjectConfiguration Include="Release|x64">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>x64</Platform>
|
<Platform>x64</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<VCProjectVersion>17.0</VCProjectVersion>
|
<VCProjectVersion>17.0</VCProjectVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<ProjectGuid>{0d89d366-f1ee-4ff3-af21-0e209449319e}</ProjectGuid>
|
<ProjectGuid>{0d89d366-f1ee-4ff3-af21-0e209449319e}</ProjectGuid>
|
||||||
<RootNamespace>threads</RootNamespace>
|
<RootNamespace>threads</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="Shared">
|
<ImportGroup Label="Shared">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
</ClCompile>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<Link>
|
</ClCompile>
|
||||||
<SubSystem>Console</SubSystem>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
</ItemDefinitionGroup>
|
</Link>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
</ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<ClCompile>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<SDLCheck>true</SDLCheck>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<SDLCheck>true</SDLCheck>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<Link>
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
<SubSystem>Console</SubSystem>
|
</ClCompile>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<Link>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
</Link>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
</ItemDefinitionGroup>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<ItemGroup>
|
</Link>
|
||||||
<ClCompile Include="main.c" />
|
</ItemDefinitionGroup>
|
||||||
</ItemGroup>
|
<ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<ClCompile Include="main.c" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
</ItemGroup>
|
||||||
</ImportGroup>
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user