-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dawidd6/master
Update from upstream
- Loading branch information
Showing
29 changed files
with
725 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ignore | ||
* | ||
|
||
# Unignore | ||
!*.cpp | ||
!*.hpp | ||
!Makefile | ||
!*.md | ||
!.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
language: cpp | ||
|
||
addons: | ||
apt: | ||
packages: | ||
- clang | ||
- gcc | ||
|
||
script: | ||
- make CXX=clang++ | ||
- make clean | ||
- make CXX=g++ | ||
- make clean | ||
|
||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
on_success: always | ||
on_failure: always |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#Assembled by dawidd6 | ||
CXX=g++ | ||
PROGRAM=bundle | ||
DESTDIR=/usr/bin/ | ||
SRC=$(wildcard src/*.cpp) | ||
OBJ=$(SRC:.cpp=.o) | ||
START_COLOR=\033[0;33m | ||
CLOSE_COLOR=\033[m | ||
|
||
src/%.o: src/%.cpp | ||
@echo "$(START_COLOR)[CXX]$(CLOSE_COLOR) $<" | ||
@$(CXX) -c -o $@ $< | ||
|
||
bin/$(PROGRAM): $(OBJ) | ||
@echo "$(START_COLOR)[CXX]$(CLOSE_COLOR) $@" | ||
@mkdir -p bin | ||
@$(CXX) -o $@ $^ | ||
|
||
install: | ||
@echo "$(START_COLOR)[IN]$(CLOSE_COLOR) $(DESTDIR)$(PROGRAM)" | ||
@install bin/$(PROGRAM) $(DESTDIR) | ||
|
||
uninstall: | ||
@echo "$(START_COLOR)[RM]$(CLOSE_COLOR) $(DESTDIR)$(PROGRAM)" | ||
@rm -rf $(DESTDIR)$(PROGRAM) | ||
|
||
objclean: | ||
@echo "$(START_COLOR)[RM]$(CLOSE_COLOR) src/*.o" | ||
@rm -rf $(OBJ) | ||
|
||
binclean: | ||
@echo "$(START_COLOR)[RM]$(CLOSE_COLOR) bin" | ||
@rm -rf bin | ||
|
||
clean: binclean objclean | ||
|
||
.PHONY: install uninstall binclean objclean clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Bundle program | ||
[![Build Status](https://travis-ci.org/dawidd6/bundle.svg?branch=master)](https://travis-ci.org/dawidd6/bundle) [![Code Health](https://landscape.io/github/dawidd6/bundle/master/landscape.svg?style=flat)](https://landscape.io/github/dawidd6/bundle/master) | ||
|
||
### Installing from source | ||
```sh | ||
git clone https://github.com/dawidd6/bundle.git | ||
cd bundle | ||
make | ||
sudo make install | ||
``` | ||
### Usage | ||
To print help message, type | ||
```sh | ||
bundle | ||
``` | ||
or | ||
```sh | ||
bundle -h | ||
``` | ||
or | ||
```sh | ||
bundle --help | ||
``` | ||
### License | ||
##### BSD | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "bundle.hpp" | ||
|
||
unsigned long long hex2dec(string x) | ||
{ | ||
unsigned long long n; | ||
stringstream ss; | ||
ss << hex << uppercase << x; | ||
ss >> n; | ||
return n; | ||
} | ||
|
||
int expo (int x, int y) | ||
{ | ||
int i = y, r = 1; | ||
if (y == 0) return 1; | ||
else if (y == 1) return x; | ||
else | ||
{ | ||
while (i != 0) | ||
{ | ||
r = r * x; | ||
i--; | ||
} | ||
return r; | ||
} | ||
} | ||
|
||
void all2dec (char *x, char *y) | ||
{ | ||
string h = x; | ||
int k = atoi(y); | ||
if (k == 16) cout << h << "(" << k << ")" << " = " << hex2dec(h) << "(10)" << endl; | ||
else | ||
{ | ||
int j = h.length() - 1, r = 0; | ||
for (unsigned int i = 0; i < h.length(); i++) | ||
{ | ||
char p = h[i]; | ||
int z = p - '0'; | ||
r = r + (z * expo (k, j)); | ||
j--; | ||
} | ||
cout << h << "(" << k << ")" << " = " << r << "(10)" << endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "bundle.hpp" | ||
|
||
void armstrong(char *x) | ||
{ | ||
int n, T[100]; | ||
signed int i, sum ; | ||
string number = x; | ||
i=0; | ||
for(n=number.length();n>0;n--) | ||
{ | ||
T[i]=number[i]-48; | ||
i++; | ||
} | ||
n=number.length(); | ||
for(i=0;i<n;i++) | ||
{ | ||
sum=sum+pow(T[i],n); | ||
if(n==1) cout << number << " is not Armstrong number" << endl; | ||
else if(sum==atoi(number.c_str())) cout << number << " is Armstrong number" << endl; | ||
} | ||
if(sum!=atoi(number.c_str())) cout << number << " is not Armstrong number" << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "bundle.hpp" | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
if (argc == 1) help(); | ||
else | ||
{ | ||
string arg = argv[1]; | ||
if ((arg == "-h") or (arg == "--help")) help(); | ||
else if (((arg == "-p") or (arg == "--primenumbers")) and (argc > 2) and (argc < 4)) prime_numbers (argv[2]); | ||
else if (((arg == "-f") or (arg == "--factorial")) and (argc > 2) and (argc < 4)) factorial (argv[2]); | ||
else if (((arg == "-d") or (arg == "--decimal2all")) and (argc > 3) and (argc < 5)) dec2all (argv[2], argv[3]); | ||
else if (((arg == "-a") or (arg == "--all2decimal")) and (argc > 3) and (argc < 5)) all2dec (argv[2], argv[3]); | ||
else if (((arg == "-s") or (arg == "--schedule")) and (argc > 2) and (argc < 4)) schedule (argv[2]); | ||
else if (((arg == "-e") or (arg == "--exponentiation")) and (argc > 3) and (argc < 5)) exponentiation (argv[2], argv[3]); | ||
else if (((arg == "-cd") or (arg == "--caesardecode")) and (argc > 2)) | ||
{ | ||
for (int i = 2; i<argc; i++) caesar_decode (argv[i]); | ||
cout << endl; | ||
} | ||
else if (((arg == "-ce") or (arg == "--caesarencode")) and (argc > 2)) | ||
{ | ||
for (int i = 2; i<argc; i++) caesar_encode (argv[i]); | ||
cout << endl; | ||
} | ||
else if (((arg == "-me") or (arg == "--morseencode")) and (argc > 2)) | ||
{ | ||
for (int i = 2; i<argc; i++) morse_encode (argv[i]); | ||
cout << endl; | ||
} | ||
else if (((arg == "-md") or (arg == "--morsedecode")) and (argc > 2)) | ||
{ | ||
for (int i = 2; i<argc; i++) morse_decode (argv[i]); | ||
cout << endl; | ||
} | ||
else if (((arg == "-b") or (arg == "--bubblesort")) and (argc > 2)) | ||
{ | ||
int t[argc]; | ||
for (int i = 2; i<argc; i++) t[i - 2] = atoi(argv[i]); | ||
sort (t, argc-2); | ||
cout << endl; | ||
} | ||
else if (((arg == "-m") or (arg == "--minmax")) and (argc > 2)) | ||
{ | ||
int t[argc]; | ||
for (int i = 2; i<argc; i++) t[i - 2] = atoi(argv[i]); | ||
min_max (t, argc-2); | ||
} | ||
else if (((arg == "-n") or (arg == "--fibonacci")) and (argc > 2) and (argc < 4)) fibonacci (argv[2]); | ||
else if (((arg == "-eu") or (arg == "--euklides")) and (argc > 3) and (argc < 5)) euklides (argv[2], argv[3]); | ||
else if (((arg == "-r") or (arg == "--readfile")) and (argc > 2) and (argc < 4)) fileoutput (argv[2]); | ||
else if (((arg == "-w") or (arg == "--writetofile")) and (argc > 3) and (argc < 5)) fileinput (argv[2], argv[3]); | ||
else if (((arg == "-ff") or (arg == "--findinfile")) and (argc > 3) and (argc < 5)) filefind (argv[2], argv[3]); | ||
else if (((arg == "-ar") or (arg == "--armstrong")) and (argc > 2) and (argc < 4)) armstrong (argv[2]); | ||
else if (((arg == "-pd") or (arg == "--palindrome")) and (argc > 2) and (argc < 4)) palindrome (argv[2]); | ||
else | ||
{ | ||
cerr << "bundle: wrong argument\n" << "Write „bundle --help” for informations\n"; | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef BUNDLE_INCLUDE | ||
#define BUNDLE_INCLUDE | ||
#include <iostream> | ||
#include <cstdlib> | ||
#include <string> | ||
#include <sstream> | ||
#include <fstream> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
unsigned long long hex2dec (string x); | ||
int expo (int x, int y); | ||
void all2dec (char *x, char *y); | ||
void dec2all (char *x, char *y); | ||
void caesar_encode (char *x); | ||
void caesar_decode (char *x); | ||
void euklides (char *x, char *y); | ||
void exponentiation (char *x, char *y); | ||
void factorial (char *x); | ||
void fibonacci (char *x); | ||
void fileinput (char *x, char *y); | ||
void fileoutput (char *x); | ||
void help (); | ||
void min_max (int x[], int y); | ||
void morse_encode (char *x); | ||
void morse_decode (char *x); | ||
void prime_numbers (char *x); | ||
void schedule (char *x); | ||
void sort (int x[], int y); | ||
void filefind (char *x, char *y); | ||
void armstrong (char *x); | ||
void palindrome (char *x); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "bundle.hpp" | ||
|
||
void dec2all (char *x, char *y) | ||
{ | ||
int d = atoi(x), k = atoi(y), output[100]; | ||
int temp = d, j, i = 0; | ||
if(k>35) cout << "Too large numeral system for this program!" << endl; | ||
if(k>1 and k<36) | ||
{ | ||
do | ||
{ | ||
output[i] = temp%k; | ||
temp = temp/k; | ||
i++; | ||
} | ||
while (temp > 0); | ||
j = i; | ||
cout << d << "(10)" << " = "; | ||
for (i=j-1; i>=0; i--) | ||
{ | ||
if (output[i] == 10) cout << "A"; | ||
else if (output[i] == 11) cout << "B"; | ||
else if (output[i] == 12) cout << "C"; | ||
else if (output[i] == 13) cout << "D"; | ||
else if (output[i] == 14) cout << "E"; | ||
else if (output[i] == 15) cout << "F"; | ||
else if (output[i] == 16) cout << "G"; | ||
else if (output[i] == 17) cout << "H"; | ||
else if (output[i] == 18) cout << "I"; | ||
else if (output[i] == 19) cout << "J"; | ||
else if (output[i] == 20) cout << "K"; | ||
else if (output[i] == 21) cout << "L"; | ||
else if (output[i] == 22) cout << "M"; | ||
else if (output[i] == 23) cout << "N"; | ||
else if (output[i] == 24) cout << "O"; | ||
else if (output[i] == 25) cout << "P"; | ||
else if (output[i] == 26) cout << "Q"; | ||
else if (output[i] == 27) cout << "R"; | ||
else if (output[i] == 28) cout << "S"; | ||
else if (output[i] == 29) cout << "T"; | ||
else if (output[i] == 30) cout << "U"; | ||
else if (output[i] == 31) cout << "V"; | ||
else if (output[i] == 32) cout << "W"; | ||
else if (output[i] == 33) cout << "X"; | ||
else if (output[i] == 34) cout << "Y"; | ||
else if (output[i] == 35) cout << "Z"; | ||
else | ||
cout << output[i]; | ||
} | ||
cout << "(" << k << ")" << endl; | ||
} | ||
if(k<2) cout << "This numeral system does not exist!" << endl; | ||
} | ||
|
Oops, something went wrong.