diff --git a/PA1/Makefile b/PA1/Makefile new file mode 100644 index 0000000..0a48911 --- /dev/null +++ b/PA1/Makefile @@ -0,0 +1,4 @@ +all: + g++ 171044071_salih_tangel.cpp -o run +do: + g++ vector2d_2.cpp -o run diff --git a/PA1/PA1.pdf b/PA1/PA1.pdf new file mode 100644 index 0000000..65d7ba1 Binary files /dev/null and b/PA1/PA1.pdf differ diff --git a/PA1/salih_tangel_171044071.cpp b/PA1/salih_tangel_171044071.cpp new file mode 100644 index 0000000..803c7d3 --- /dev/null +++ b/PA1/salih_tangel_171044071.cpp @@ -0,0 +1,183 @@ +#include +#include +#include +using namespace std; +const int MAX = 10; //it must be max 10 if it would be unique +int is_it_error_1(char one[MAX],char two[MAX],int digit){ //check is it error 1 + int i=0; + if(strlen(one)!=strlen(two)) + return 0; + else + return 1; +} +int is_it_same(char one[MAX],char two[MAX],int digit){ //check is it finish + int i=0; + for(;i 9) + return 0; + return 1; +} +int fun_find_exact(char one[MAX], char two[MAX], int digit) { //find hint exact num + int i = 0, k = 0; + for (i = 0; i < digit; i++) { + if (one[i] == two[i]) k++; + } + return k; +} +int fun_find_wrong_placeses(char one[MAX], char two[MAX], int digit) { //find hint wrong places + int i = 0, j = 0, k = 0; + for (; i < digit; i++) { + for (j = 0; j < digit; j++) { + if (one[i] == two[j] && i != j) k++; + } + } + return k; +} +int is_it_not_int(char one[MAX]) { //check is it integer + int i = 0; + while (one[i] != '\0') { + if (!(one[i] >=48 && one[i]<=57 || one[i]== 45) ) { //between ascii value of 0 and 9 and do not touch negatif value + + return 0; + } + i++; + } + return 1; +} +int find_digit(int first, int second) { //find digit + int i = 1; int j = 1; while (first != 0 && second != 0) { + first /= 10; + second /= 10; + if (first != 0) i++; + if (second != 0) j++; + } + if (i == j) + return i; + else { + return 0; + } +} +int main(int argc, char *argv[]) { + int new_num; //int version of user num + char user_num[MAX]; //user num + char random_num[MAX]; //random generate num + int exact = 0; //exact hint + int misplaced = 0; //misplaced hint + int game_counter = 0; //game counter for 100 times + int digit, i; //digit numand i for counter + + if (0 == strcmp(argv[1], "-r")) { //random num game + if(atoi(argv[2]) > 9){ //for digit control + cout << "Error 0" << endl; + return 1; + } + do { + cin >> user_num; //take user num + new_num =atoi(user_num); // convert string to the int number + digit = find_digit(new_num,new_num); // find and return digit of numbers + + srand(time(0)); + random_num[0]=(rand() %9+1)+'0';//first digit zero case + + for (i =1; i < atoi(argv[2]); i++) { //random num part + int flag=0; + while(!flag){ + char num=rand()%10 +'0'; + if(check(random_num,num,i)){ + random_num[i]=num; + flag=1; + } + } + } + random_num[i] = '\0'; // to see end + + if (0 == is_it_not_int(user_num) ) { //these parts for error checking + cout << "Error 2" << endl; + return 1; + } + if (0 ==is_it_error_1(user_num,random_num,digit)) { + cout << "Error 1" << endl; + return 1; + } + if (0 == is_it_error_0(user_num, digit) ) { + cout << "Error 0" << endl; + return 1; + } + if(is_it_same(random_num,user_num,digit)){ + cout<<"FOUND\t"; + cout< 9){ + cout << "Error 0" << endl; + return 1; + } + new_num=0; //to we will use new_num again + do { + cin >> user_num; + cout<<"Enter A NUMBER"< +#include +#include +#include +using namespace std; + +class Image{ + public: + vector fun_open(string filename,vector v); //open part + void fun_save(string filename2,vector v); // save part + vector fun_grayscale(float red,float green,float blue,vector v);//graysclale working + float get_red(){ + return red; + } + float get_blue(){ + return blue; + } + float get_green(){ + return green; + } + string firstline; //for a3 + string secondline; //for 4 3 + string thirdline; + string fourthline; //for 255 + private: + float red;//for float varibles + float green; + float blue; +}; +vector Image :: fun_open(string filename,vector v){ + int num=0; + int i=0; + cin>>filename; + ifstream myfile; + myfile.open (filename); + if (!myfile) { //error check + cerr << "Unable to open file datafile.txt"; + exit(1); // call system to stop + } + myfile>>firstline; + myfile>>secondline; + myfile>>thirdline; + myfile>>fourthline; + while(myfile>>num){ + v.push_back(num); + } + myfile.close(); + return v; +} +void Image :: fun_save(string filename2,vector v){ //not working part + int i=0; + int counter=0; + ofstream newfile; + cin>>filename2; + newfile.open(filename2); + if (!newfile.is_open()) { + cerr << "Unable to open file datafile.txt"; + exit(1); // call system to stop + } + newfile< Image :: fun_grayscale(float red,float green,float blue,vector v){ + bool exit2=false; + int i=0; + string record2; + //for(i=0;i>red>>green>>blue; + if(red<1 && red>=0 && green<1 && green>=0 && blue<1 &&blue>=0) + exit2=false; + else{ + cout<<"wrong num"<255){ + v[i]=255; + } + } + //for(i=0;i v; + bool exit = true; + int choice; + int choice2; + string filename; + string filename2; + Image x; + do { + cout << "Main Menu" << endl + << "0-Exit" << endl + << "1-Open An Image(D)" << endl + << "2-Save Image Data(D)" << endl + << "3-Scripts(D)" << endl; + cin >> choice; + if (choice == 0) + exit = false; + else if (choice == 1) { + cout << "OPEN AN IMAGE MENU" << endl + << "0 - UP" << endl + << "1 - Enter The Name Of The Image File" << endl; + cin >> choice2; + if (choice2 == 0){} else if (choice2 == 1){ + v=x.fun_open(filename,v); + } + } else if (choice == 2) { + cout << "SAVE IMAGE DATA MENU" << endl + << "0 - UP" << endl + << "1 - Enter A File Name" << endl; + cin >> choice2; + if (choice2 == 0){} else if (choice2 == 1){ + x.fun_save(filename2,v); + return 1; + } + } else if (choice == 3) { + cout << "SCRIPTS MENU" << endl + << "0 - UP" << endl + << "1 - Convert To Grayscale(D)" << endl; + cin >> choice2; + if (choice2 == 0){} else if (choice2 == 1) { + cout<<"CONVERT TO GRAYSCALE MENU"<> choice2; + if (choice2 == 0){} else if (choice2 == 1){ + v=x.fun_grayscale(x.get_red(),x.get_green(),x.get_blue(),v); + } + } + } + } while (exit); +} + diff --git a/PA2/Makefile b/PA2/Makefile new file mode 100644 index 0000000..0a48911 --- /dev/null +++ b/PA2/Makefile @@ -0,0 +1,4 @@ +all: + g++ 171044071_salih_tangel.cpp -o run +do: + g++ vector2d_2.cpp -o run diff --git a/PA2/run b/PA2/run new file mode 100644 index 0000000..5c3277b Binary files /dev/null and b/PA2/run differ diff --git a/PA3/Makefile b/PA3/Makefile new file mode 100644 index 0000000..444dcf4 --- /dev/null +++ b/PA3/Makefile @@ -0,0 +1,8 @@ +all: + g++ -g salih_tangel_171044071.cpp -o run +do: + g++ issue.cpp -o run +delete: + rm -rf 1.cpp +segment: + valgrind -v ./run diff --git a/PA3/a.out b/PA3/a.out new file mode 100644 index 0000000..6fb0a15 Binary files /dev/null and b/PA3/a.out differ diff --git a/PA3/a.ppm b/PA3/a.ppm new file mode 100644 index 0000000..334f1a8 --- /dev/null +++ b/PA3/a.ppm @@ -0,0 +1,9 @@ +P3 +4 +4 +120 + +0 0 0 5 0 0 0 0 0 6 0 6 +0 0 0 0 6 8 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 8 0 0 0 +1 0 6 0 0 0 0 0 0 6 6 6 \ No newline at end of file diff --git a/PA3/b.ppm b/PA3/b.ppm new file mode 100644 index 0000000..321864b --- /dev/null +++ b/PA3/b.ppm @@ -0,0 +1,9 @@ +P3 +4 +4 +120 + +0 0 0 50 0 0 0 0 0 60 0 60 +0 0 0 0 60 87 0 0 0 0 0 0 +0 0 0 0 0 0 0 7 87 0 0 0 +60 0 60 0 0 0 0 0 0 60 60 60 \ No newline at end of file diff --git a/PA3/b1.ppm b/PA3/b1.ppm new file mode 100644 index 0000000..321864b --- /dev/null +++ b/PA3/b1.ppm @@ -0,0 +1,9 @@ +P3 +4 +4 +120 + +0 0 0 50 0 0 0 0 0 60 0 60 +0 0 0 0 60 87 0 0 0 0 0 0 +0 0 0 0 0 0 0 7 87 0 0 0 +60 0 60 0 0 0 0 0 0 60 60 60 \ No newline at end of file diff --git a/PA3/run b/PA3/run new file mode 100644 index 0000000..6006ba4 Binary files /dev/null and b/PA3/run differ diff --git a/PA3/salih_tangel_171044071.cpp b/PA3/salih_tangel_171044071.cpp new file mode 100644 index 0000000..6ed3bf7 --- /dev/null +++ b/PA3/salih_tangel_171044071.cpp @@ -0,0 +1,291 @@ +#include +#include +#include +using namespace std; +//GRAYSCALE YAPMADAN KAYDEDINCE HATA VERIYOR +//= KISMINI ACINCADA DA HATA VERIYOR +class Image { + public: + void fun_open(); + void fun_save(); + void fun_grayscale(); + Image() { + } // Default constructor + Image(const Image &p2) { + int i,j; + cin>>filename; + imageformat=p2.imageformat; + rowcount=p2.rowcount; + columncount=p2.columncount; + maxcolorvalue=p2.maxcolorvalue; + RGB = new int*[rowcount];// d. memory + for(int i = 0; i < rowcount; i++) + { + RGB[i]=new int[columncount*3]; + } + for(i=0;i newImage.maxcolorvalue) + newImage.RGB[i][j]=newImage.maxcolorvalue; + } + } + return newImage; +} +void Image::operator = (const Image &obj) { + int i=0,j=0; + RGB[i][j]=obj.RGB[i][j]; +} +void Image ::fun_open() { + int i = 0; + int j = 0; + + cin >> filename; + + ifstream myfile; + myfile.open(filename); + if (!myfile) { // error check + cerr << "Unable to open file datafile.txt"; + exit(1); // call system to stop + } + myfile >> imageformat; + myfile >> rowcount; + myfile >> columncount; + myfile >> maxcolorvalue; + + RGB = new int*[rowcount];// d. memory + for(int i = 0; i < rowcount; i++) + { + RGB[i]=new int[columncount*3]; + } + i=0,j=0; + while (!myfile.eof()) { + if (j == columncount*3) { //bir satir bitince + i++; + j = 0; + } + myfile >> RGB[i][j]; + j++; + } + myfile.close(); +} +void Image ::fun_save() { + int i=0,j=0; + + int choice; + ofstream newfile; + cout<<"Please enter a name"<> filename2; + + newfile.open(filename2); + if (!newfile.is_open()) { + cerr << "Unable to open file datafile"; + exit(1); // call system to stop + } + // this part for first three lines + newfile << imageformat << endl; + newfile << rowcount <> red >> green >> blue; + if (red < 1 && red >= 0 && green < 1 && green >= 0 && + blue < 1 && blue >= 0) + exit2 = false; + else { + cout << "wrong num" << endl; + exit2 = true; + } + } while (exit2); + + for(i=0;imaxcolorvalue){ + RGB[i][j]=maxcolorvalue; + } + } + } +} +int main() { + bool exit = true; + int choice1; + int choice2; + int image_choice; + int grayscale_choice; + string thirdImage_name; + string filename2; + Image myImage; + Image secondImage; + Image thirdImage; + int i,j; + do { + cout << "Main Menu" << endl + << "0-Exit" << endl + << "-1-Load two Image(D)" << endl + << "1-Open An Image(D)" << endl + << "2-Save Image Data(D)" << endl + << "3-Scripts(D)" << endl + << "4-Add two image" << endl; + cin >> choice1; + if (choice1 == 0) + exit = false; + else if (choice1 == -1) { + cout << "OPEN TWO IMAGES(you should go to open image from menu too)" << endl + << "0 - UP" << endl + << "1 - Enter The Name Of The Image File" << endl; + cin >> choice2; + if (choice2 == 0) { + // do nothing + } else if (choice2 == 1) { + secondImage.fun_open(); + } + } else if (choice1 == 1) { + cout << "OPEN AN IMAGE MENU" << endl + << "0 - UP" << endl + << "1 - Enter The Name Of The Image File" << endl; + cin >> choice2; + if (choice2 == 0) { + // do nothing + } else if (choice2 == 1) { + myImage.fun_open(); + } + } else if (choice1 == 2) { + cout << "SAVE IMAGE DATA MENU" << endl + << "0 - UP" << endl + << "1- GO ON"<> choice2; + if (choice2 == 0) { + // do nothing + } else if(choice2 ==1){ + cout << "which image do you like to save ?"<> image_choice; + if (image_choice == 1) + myImage.fun_save(); + else if (image_choice == 2) + secondImage.fun_save(); + else if (image_choice == 3) + thirdImage.fun_save(); + else { + cout << "you entered wrong" << endl; + } + return 1; + } + } else if (choice1 == 3) { + cout << "SCRIPTS MENU" << endl + << "0 - UP" << endl + << "1 - Convert To Grayscale(D)" << endl; + cin >> choice2; + + if (choice2 == 0) { + // do nothing + } else if (choice2 == 1) { + cout << "CONVERT TO GRAYSCALE MENU" << endl + << "0 - UP" << endl + << "1 - Enter Coefficients For RED GREEN " + "And BLUE Channels." + << endl; + cin >> choice2; + + if (choice2 == 0) { + } else if (choice2 == 1) { + cout << "which image do you like to Grayscale?"<> grayscale_choice; + if (grayscale_choice == 1) + myImage.fun_grayscale(); + else if (grayscale_choice == 2) + secondImage.fun_grayscale(); + else if (grayscale_choice == 3) + thirdImage.fun_grayscale(); + else { + cout << "you entered wrong" << endl; + } + } + } + } else if (choice1 == 4) { + cout << "ADD IMAGES " << endl + << "0 - UP" << endl; + if (choice2 == 0) { + // do nothing + }else if(choice2 ==1){ + cout<<"write the name of the third image"< +#include +using namespace std; +class Creature{ +public: + string getSpecies();// a helper function which returns the creature type + Creature(); + // Initialize to human, 10 strength, 10 hit points + Creature(int newType, int newStrength, int newHit); + // Also add appropriate accessor and mutator functions + int get_type()const; + int get_strength()const; + int get_hitpoints()const; + void set_type(const int newType); + void set_strength(const int newStrength); + void set_hitpoints(const int hitpoints); + // for type, strength, and hit points + int getDamage(); + // Returns amount of damage this creature + // inflicts in one round of combat + private: + int type; + int strength; + int hitpoints; +}; +#endif diff --git a/PA4/salih_tangel_171044071/Creature.o b/PA4/salih_tangel_171044071/Creature.o new file mode 100644 index 0000000..2f92003 Binary files /dev/null and b/PA4/salih_tangel_171044071/Creature.o differ diff --git a/PA4/salih_tangel_171044071/Cyberdemon.cpp b/PA4/salih_tangel_171044071/Cyberdemon.cpp new file mode 100644 index 0000000..b8c3b8a --- /dev/null +++ b/PA4/salih_tangel_171044071/Cyberdemon.cpp @@ -0,0 +1,44 @@ +#include"Cyberdemon.h" +Cyberdemons::Cyberdemons(){ + set_type(1); + set_strength(10); + set_hitpoints(10); +} +Cyberdemons::Cyberdemons(int newType, int newStrength, int newHit){ + set_type(newType); + set_strength(newStrength); +} +int Cyberdemons:: getDamage(){ + int damage; + int change=rand() % 100; + // All creatures inflict damage which is a + // random number up to their strength + damage = (rand() % get_strength()) + 1; + cout << getSpecies() << " attacks for " << damage << " points!" + << endl; + // Demons can inflict damage of 50 with a 5% chance + if ((get_type()== 2) || (get_type()== 1)){ + if(change<5); + damage+=50; + cout<<"Demonic attack inflict 50"<< + "additional damage point!"< Homeworks, origin/Homeworks, origin/HEAD) +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Sun May 9 19:44:28 2021 +0300 + + Create Readme.md + +commit 11fa081ec8c5cc3cb1e6d23a941a1b87d6593471 +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Sun May 9 19:40:51 2021 +0300 + + Update README.md + +commit ac9168a24df7afcde0eb16ffa50a21735f0b4834 (origin/java) +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:18:46 2020 +0300 + + Add files via upload + +commit c0ebba3781e164d9a901cafe850de639f51b9b3f (origin/master) +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:09:42 2020 +0300 + + Create README.md + +commit fde856a5987b79e408701a6d5bbb157f6689bc86 +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:08:57 2020 +0300 + + Add files via upload + +commit 05ab7ccadffbf727d6197629f49df105fc833aa0 +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:08:26 2020 +0300 + + Add files via upload + +commit 6459d44c03fac63dcb9c1673f01d1815a4b447bc +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:07:44 2020 +0300 + + Add files via upload + +commit caf700ecda9e1f85167334b343c3d39090b13dae +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:07:20 2020 +0300 + + Add files via upload + +commit 1af192e07c073013c2798fcafcadd7ceab577f06 +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:06:34 2020 +0300 + + Add files via upload + +commit b63dda3831da3c1403e15726bae73ba0e5afadf3 +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 20:06:06 2020 +0300 + + Add files via upload + +commit 0a922bb71dc078c90f11318afa3950368c3fc98b +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 18:43:12 2020 +0300 + + Add files via upload + +commit b77edef89c18b6a891ee7b34956fe53a53f2ee7f +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 18:42:27 2020 +0300 + + Add files via upload + +commit 31db44aba8efa4a3d5aaf641e55c6a6b3ebc6c0b +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 18:41:08 2020 +0300 + + Add files via upload + +commit dfbd27a665d4c1dae1fd465e1be9ec43b0e545de +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 18:40:06 2020 +0300 + + Add files via upload + +commit 64246c1dec2c47438f46014338f39a6ab29f09af +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 18:39:18 2020 +0300 + + Add files via upload + +commit 4a152f3811819649981efbb54674c65911a9a777 +Author: salihtangel <47741948+salihtangel@users.noreply.github.com> +Date: Tue Jul 7 18:38:40 2020 +0300 + + Add files via upload diff --git a/psdeneme/1.c b/psdeneme/1.c new file mode 100644 index 0000000..7ebcfa7 --- /dev/null +++ b/psdeneme/1.c @@ -0,0 +1 @@ +asfasdasddasd