Skip to content

Instantly share code, notes, and snippets.

View andraantariksa's full-sized avatar
🦀

Andra Antariksa andraantariksa

🦀
View GitHub Profile
#include <iostream>
#include <fstream>
#include <iomanip>
int main(int argc, const char *argv[]){
std::string name, surname, city;
std::fstream file;
file.open("output.txt", std::fstream::in | std::fstream::out | std::fstream::app);
std::cout << "Write the detail with these format. Press <Ctrl+D> to send EOF to program.\nName Surname City\n";
if(file.peek() == std::ifstream::traits_type::eof()){
#include <iostream>
int main(int argc, const char *argv[]){
float distance, fuel;
std::cout << "Distance traveled in mile:\n";
std::cin >> distance;
std::cout << "Fuel used in gallon:\n";
std::cin>> fuel;
std::cout << fuel / distance << " gallon/mile\n";
return 0;
#include <iostream>
#include <iomanip>
#include <cstring>
class Sales{
private:
long int sales[4][5];
public:
Sales(){
memset(sales, 0, sizeof sales);
@andraantariksa
andraantariksa / linkedlist.h
Created July 13, 2019 18:23
Simple Linked List implementation
#ifndef linkedlist_header_
#define linkedlist_header_
#include <functional>
namespace LinkedList{
template <class T>
class Node
{
public:
T data;
@andraantariksa
andraantariksa / fact.cpp
Last active September 6, 2019 10:23
Factorial Recursive
#include <cstring>
#include <cstdio>
#include <cstdlib>
int long solve_factorial(long int *factorial_memoization, int length, int long n = 1, int index = 0)
{
*(factorial_memoization +index) = n;
// printf("Check of %d is %ld\n", index, factorial_memoization[index]);
#include <string>
#include <cstdlib>
#include <cstdio>
#include <iostream>
struct student {
int id;
std::string name;
int age;
char gender;
@andraantariksa
andraantariksa / RBTree.cpp
Last active December 4, 2019 03:33
Red-Black Tree Implementation
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#if defined(_WIN32)
#define PLATFORM_WINDOWS // Windows
@andraantariksa
andraantariksa / AVL-tree.cpp
Created December 4, 2019 03:45
AVL Tree Implementation
#if defined(_WIN32)
#define PLATFORM_WINDOWS // Windows
#elif defined(_WIN64)
#define PLATFORM_WINDOWS // Windows
#elif defined(__CYGWIN__) && !defined(_WIN32)
#define PLATFORM_WINDOWS // Windows (Cygwin POSIX under Microsoft Window)
#elif defined(__linux__)
#define PLATFORM_LINUX // Debian, Ubuntu, Gentoo, Fedora, openSUSE, RedHat, Centos and other
#endif
@andraantariksa
andraantariksa / SDL Audio.cpp
Created January 13, 2020 16:07
SDL simple record and playback
#include <SDL.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <ctime>
const int MAX_RECORDING_DEVICES = 10;