Commit 46c99632 authored by Tomáš Juřena's avatar Tomáš Juřena

Initial release

parents
BasedOnStyle: Google
IndentWidth: 2
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
---
Language: Cpp
ColumnLimit: 160
Standard: Cpp11
SortIncludes: true
---
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCtreator CMake
CMakeLists.txt.user*
CMakeCache.txt
cmake_install.cmake
CMakeFiles
bin/
lib/
cmake_minimum_required(VERSION 2.8)
project(stringFunctions C)
file(GLOB sources "*.c")
file(GLOB headers "*.h")
add_compile_options(-std=c99)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_executable(${PROJECT_NAME} ${sources} ${headers})
# Řetězce v C - zadání
Tento repozitář obsahuje zadání pro práci s řezetci v jazyce C.
Projekt je napsán pro vývojové prostředí Qt creator ve formátu qmake, qbs, cmake a makefile.
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "staticAnalyze.h"
/* Private typedef -----------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
#define ARRAY_LEN (0x100)
#define OUTPUT_LEN (0x400)
/* Private variables ---------------------------------------------------------*/
/* Private function declarations ---------------------------------------------*/
/* Exported functions definitions --------------------------------------------*/
/* Private function definitions ----------------------------------------------*/
int main() {
char *data =
"13,654,24,48,1,79,14456,-13,654,13,46,465,0,65,16,54,1,67,4,6,74,165,"
"4,-654,616,51,654,1,654,654,-61,654647,67,13,45,1,54,2,15,15,47,1,54";
int array[ARRAY_LEN];
unsigned int loaded = StaticAnalyze_load(data, ',', array, ARRAY_LEN);
if (loaded > 0) {
char output[OUTPUT_LEN] = {0};
StaticAnalyze_process(array, loaded, output, OUTPUT_LEN);
printf("%s", output);
}
return 0;
}
IDIR=.
CC?=gcc
CFLAGS=-I$(IDIR)
ODIR=obj
BINDIR=bin
LIBS=
MKDIR_P = mkdir -p
RM = rm -f
RMDIR = rm -rf
TARGET = stringFunctions
.PHONY: directories
all: directories $(TARGET)
directories: $(ODIR)
${ODIR}:
$(MKDIR_P) $(ODIR)
$(MKDIR_P) $(BINDIR)
_DEPS = staticAnalyze.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o staticAnalyze.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJ)
$(CC) -o $(BINDIR)/$@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
$(RMDIR) $(ODIR)
$(RMDIR) $(BINDIR)
/**
******************************************************************************
* @file staticAnalyze.h
* @author Tomas Jurena
* @brief
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 Tomas Juřena.
* All rights reserved.</center></h2>
*
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
*
******************************************************************************
*/
#ifndef STATICANALYZE_H
#define STATICANALYZE_H
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported variables --------------------------------------------------------*/
/* Exported functions declarations -------------------------------------------*/
/**
* @brief Tato fce zpracovava vstupni formatovany retezec do predaneho pole az
* do maximalni delky. Retezec je sekvence celych cisel oddelena oddelovacem.
* Pokud je nactena naplatne cislo, je toto cislo zahozeno.
* @param[in] input Vstupni formatovany rezetec
* @param[in] delimiter Oddelovac jednotlivych cisel
* @param[out] array Vystupni pole, kam budou ulozeny nactena cisla
* @param[in] length Delka vystupniho pole
* @return Pokud nedojde k chybe pri osetreni vstupnich parametru, je vracen
* pocet nactenych cisel, jinak je vracena hodnota 0.
*/
unsigned int StaticAnalyze_load(const char *input, char delimiter, int *array,
unsigned int length);
/**
* @brief Funkce, ktera ze vstupniho pole spocita prumer a smerodatnou odchylku,
* a vyhleda minimalni a maximalni hodnotu. Vystup bude zapsan do predaneho
* argumentu output. Pri zapisu je treba zajistit, ze nebude zapsano za rozsah
* pameti.
*
* Format bude nasledujici, kde symbol "xxx" znaci cele cislo a "yyy" realne
* cislo vypsane ve vedeckem formatu:
* Minimum: xxx
* Maximum: xxx
* Prumer: yyy
* Smerodatna odchylka: yyy
*
* @param[in] input Vstupni pole
* @param[in] length Delka vstupniho pole
* @param[out] output Vystupni retezec
* @param[in] outputLen Delka vystupniho retezce
*/
void StaticAnalyze_process(const int *input, unsigned int length, char *output,
unsigned int outputLen);
#endif // STATICANALYZE_H
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.c \
staticAnalyze.c
HEADERS += \
staticAnalyze.h
import qbs
CppApplication {
consoleApplication: true
files: [
"staticAnalyze.c",
"staticAnalyze.h",
"main.c",
]
Group { // Properties for the produced executable
fileTagsFilter: "application"
qbs.install: true
qbs.installDir: "bin"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment