Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 1-ConsecutiveHeads/ConsecutiveHeads.pro
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ unix:!macx {
QMAKE_CXXFLAGS += -Wno-unused-const-variable
LIBS += -ldl
}

#
# increase system stack size (helpful for recursive programs)
win32 {
QMAKE_LFLAGS += -Wl,--stack,536870912
LIBS += -lDbghelp
LIBS += -lbfd
LIBS += -liberty
# LIBS += -liberty
LIBS += -limagehlp
}
macx {
Expand Down
259 changes: 259 additions & 0 deletions 1-ConsecutiveHeads/ConsecutiveHeads.pro.user.b17a978

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions 1-ConsecutiveHeads/src/ConsecutiveHeads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@
#include "random.h"
using namespace std;

//make function throw coin
void throwCoin()
{
int tryCounter = 0; //count the repetition of cycle
int b = 0; //if b=3 it mean that we have 3 heads in a row if we have tails then we make b=0.
while(b<3){
int i = randomInteger(0,1);
if(i == 1){
cout << "heads" << endl;
b += 1;
}else{
cout << "tails" << endl;
b = 0;
}
tryCounter+=1;
}
cout << "It take " << tryCounter << " try to get 3 heads in row" << endl;
}
int main() {
// TODO: fill in the code
return 0;

throwCoin();

return 0;
}
2 changes: 1 addition & 1 deletion 2-Obenglobish/Obenglobish.pro
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ win32 {
QMAKE_LFLAGS += -Wl,--stack,536870912
LIBS += -lDbghelp
LIBS += -lbfd
LIBS += -liberty
# LIBS += -liberty
LIBS += -limagehlp
}
macx {
Expand Down
259 changes: 259 additions & 0 deletions 2-Obenglobish/Obenglobish.pro.user.b17a978

Large diffs are not rendered by default.

65 changes: 63 additions & 2 deletions 2-Obenglobish/src/Obenglobish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,68 @@
#include "strlib.h"
using namespace std;

string obenglobish(string word);
bool vowelCheck(char i);
int main() {
// TODO: fill in the code
return 0;
// TODO: fill in the code
while(true){
string word = getLine("Enter word: ");
if(word == ""){
break;
}
string translation = obenglobish(word);
cout << word << " -> " << translation << endl;
}
return 0;
}

string obenglobish(string wordTmp){
string res = "";
string word = toLowerCase(wordTmp);
int wLen = word.length();
char last = word[wLen-1];
int cheking = 0; //need to check if word ends on "e" letter
//check if entered word end with "e", if true - set cheking = 1;
if(last == char(101)){
word = word.substr(0,word.length()-1);
cout << "trim word - " << word << endl;
cheking = 1;
}
//start change entered word.
//compare entered word with vowelletter char by char
for(int i = 0; i<word.length(); i++){
if(i != 0){
if(vowelCheck(word[i]) == true && vowelCheck(word[i-1]) == false ){
res += "ob";
}
}
if(i == 0){
if(vowelCheck(word[i]) == true){
res += "ob";
}
}
//if char is not vowel just add to res
res += word[i];
}
//adding the "e" letter to res
if(cheking == 1){
res += "e";
}
return res;
}

//method check if char is vowel and return true or false
bool vowelCheck(char i){
bool res;
string vowelLetter = "aioue";
for(int j = 0; j < vowelLetter.length(); j++){
if(i == vowelLetter[j]){
res = true;
break;
}else{
res = false;
}

}
return res;
}
2 changes: 1 addition & 1 deletion 3-NumericConversion/NumericConversion.pro
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ win32 {
QMAKE_LFLAGS += -Wl,--stack,536870912
LIBS += -lDbghelp
LIBS += -lbfd
LIBS += -liberty
# LIBS += -liberty
LIBS += -limagehlp
}
macx {
Expand Down
259 changes: 259 additions & 0 deletions 3-NumericConversion/NumericConversion.pro.user.b17a978

Large diffs are not rendered by default.

63 changes: 61 additions & 2 deletions 3-NumericConversion/src/NumericConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,68 @@ using namespace std;
// Function prototypes
string intToString(int n);
int stringToInt(string str);
string reverseString(string src);


int main() {
// TODO: fill in the code
return 0;
string r = intToString(-1234567);
//print in console converted integer and show first symbol of string
cout << "This is string " << r << ". First element of string - " << r[0] << endl;

string st = "457";
int t = stringToInt(st);
//print in console converted string. and to prove it what it number multiple on 2
cout << "Number is - " << t << ". Make it double - " << t * 2 << endl;
return 0;
}
//transforms string into integer with help of recursion
int stringToInt(string str){
int res = 0;
int minus = 0;
//if we got minus
if(str[0] == char(45)){
cout << "stroka do - " << str << endl;
str = str.substr(1, str.length()-1);
cout << "stroka posle - " << str << endl;
minus = 1;
}
if(str.length() == 1){
char a = str[0];
int b =((int) a) - 48;
return res = b;
}
res =(((int) str[str.length()-1]) - 48) + 10 * stringToInt(str = str.substr(0,str.length() - 1)) ;
if(minus == 1){
res = res * (-1);
}
return res;
}

//transforms integer to string with help of recursion
string intToString(int n){
string res;
int minus = 0;
//if we got minus
if(n < 0 ){
//cout << "chislo do - " << n << endl;
n = n * (-1);
//cout << "chislo posle - " << n << endl;
minus = 1;
}
if(n < 10){
return res = char(n + 48);
}
res = (intToString(n / 10)+char((n % 10) + 48)); //48 = 0
if(minus == 1){
res =char(45) + res;
}
return res;
}

//reverse string with help of recursion
//string reverseString(string src){
// if(src == ""){
// return src;
// }
// return (src[src.length() - 1]) + reverseString(src.substr(0, src.length() - 1));
//}
5 changes: 3 additions & 2 deletions 4-Flesch-Kincaid/FleschKincaid.pro
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ exists($$PWD/*.cpp) {
SOURCES += $$PWD/*.cpp
}

HEADERS += $$PWD/lib/StanfordCPPLib/*.h
HEADERS += $$PWD/lib/StanfordCPPLib/*.h \
src/b.h
HEADERS += $$PWD/lib/StanfordCPPLib/private/*.h
HEADERS += $$PWD/lib/StanfordCPPLib/stacktrace/*.h
exists($$PWD/src/*.h) {
Expand Down Expand Up @@ -110,7 +111,7 @@ win32 {
QMAKE_LFLAGS += -Wl,--stack,536870912
LIBS += -lDbghelp
LIBS += -lbfd
LIBS += -liberty
# LIBS += -liberty
LIBS += -limagehlp
}
macx {
Expand Down
Loading