diff --git a/15 May 2020/Q1_15_05_2020 - Output.PNG b/15 May 2020/Q1_15_05_2020 - Output.PNG new file mode 100644 index 0000000..9af4364 Binary files /dev/null and b/15 May 2020/Q1_15_05_2020 - Output.PNG differ diff --git a/15 May 2020/Q1_15_05_2020.cpp b/15 May 2020/Q1_15_05_2020.cpp new file mode 100644 index 0000000..4166cf4 --- /dev/null +++ b/15 May 2020/Q1_15_05_2020.cpp @@ -0,0 +1,77 @@ +#include +#include +using namespace std; +int run =0; + +class team{ + public : + + int run = 0; + int ball=0,input,count=0; + vector m1({-2,-1,0,1,2,3,4,5,6}); + + int SuperOver(){ + while(ball<6){ + cin>>input; + if(input == (-2)) + ball++; + else if(input == (-1)) + run++; + + else if(input == 0) + ball++; + + else if(input == (1)){ + run++; + ball++; + } + + else if(input == 2){ + run+=2; + ball++; + } + else if(input == 3){ + run+=3; + ball++; + } + + else if(input == 4){ + run+=4; + ball++; + } + else if(input == 5){ + run+=4; + ball++; + } + else if(input == 6){ + run+=6; + ball++; + } + + else + cout<<"Envalid Entry"< m1({-2,-1,0,1,2,3,4,5,6}); + team Team1 , Team2; + cout<<"Team1 :: Bowling and Team2 :: Batting "<= j: + ls[i][j] = ls[i-1][j] + ls[i][j-1] + else: + break + return ls[-1][-1] + + +n = int(input("Enter array size:")) +print(path_of_grid(n) % (10 ^ 9 + 7)) \ No newline at end of file diff --git a/Mohammad Farukh/11 May 2020/Q5_11 May 2020- Output.PNG b/Mohammad Farukh/11 May 2020/Q5_11 May 2020- Output.PNG new file mode 100644 index 0000000..36d8c57 Binary files /dev/null and b/Mohammad Farukh/11 May 2020/Q5_11 May 2020- Output.PNG differ diff --git a/Mohammad Farukh/11 May 2020/Q5_11 May 2020.py b/Mohammad Farukh/11 May 2020/Q5_11 May 2020.py new file mode 100644 index 0000000..1cba0c2 --- /dev/null +++ b/Mohammad Farukh/11 May 2020/Q5_11 May 2020.py @@ -0,0 +1,27 @@ +def sqrtSearch(low, high, N): + # If the range is still valid + if (low <= high): + + # Find the mid-value of the range + mid = (low + high) // 2; + + # Base Case + if ((mid * mid <= N) and ((mid + 1) * (mid + 1) > N)): + return mid; + + # Condition to check if the + # left search space is useless + elif (mid * mid < N): + return sqrtSearch(mid + 1, high, N); + + else: + return sqrtSearch(low, mid - 1, N); + + return low; + + +# Driver Code +if __name__ == "__main__": + + N = float(input("Enter the Value to find the SqureRoot : ")) + print(sqrtSearch(0, N, N)) \ No newline at end of file diff --git a/Mohammad Farukh/12 May 2020/Q1_12_05_2020 - Output.PNG b/Mohammad Farukh/12 May 2020/Q1_12_05_2020 - Output.PNG new file mode 100644 index 0000000..7819cf4 Binary files /dev/null and b/Mohammad Farukh/12 May 2020/Q1_12_05_2020 - Output.PNG differ diff --git a/Mohammad Farukh/12 May 2020/Q1_12_05_2020.py b/Mohammad Farukh/12 May 2020/Q1_12_05_2020.py new file mode 100644 index 0000000..84ec7dc --- /dev/null +++ b/Mohammad Farukh/12 May 2020/Q1_12_05_2020.py @@ -0,0 +1,34 @@ +def prime(n): + if n>1: + for i in range(2,n//2): + if(n%i)==0: + return False + else: + return True + else: + return False + + +l= [ + [1,2,3,4], + [5,6,7,8], + [9,10,11,12] +] +n=3 +m=4 +count=0 +for i in range(n): + for j in range(m): + sum=0 + if 0<=i-1: + sum+=l[i-1][j] + if 0<=j-1: + sum+=+l[i][j-1] + if i+1<= n-1: + sum+=l[i+1][j] + if j+1<= m-1: + sum+=l[i][j+1] + #print(sum) + if prime(sum): + count+=1 +print("Number of adjacent prime sum",count) \ No newline at end of file diff --git a/Mohammad Farukh/12 May 2020/Q2_12_05_2020 - Output.PNG b/Mohammad Farukh/12 May 2020/Q2_12_05_2020 - Output.PNG new file mode 100644 index 0000000..ed75957 Binary files /dev/null and b/Mohammad Farukh/12 May 2020/Q2_12_05_2020 - Output.PNG differ diff --git a/Mohammad Farukh/12 May 2020/Q2_12_05_2020.py b/Mohammad Farukh/12 May 2020/Q2_12_05_2020.py new file mode 100644 index 0000000..1fa7851 --- /dev/null +++ b/Mohammad Farukh/12 May 2020/Q2_12_05_2020.py @@ -0,0 +1,45 @@ +# The Main logic + +def search(mat, n, x): + i = 0 + + # set indexes for top right element + j = n - 1 + while (i < n and j >= 0): + + if (mat[i][j] == x): + print(" n is Found at ", i, ", ", j) + return 1 + + if (mat[i][j] > x): + j -= 1 + + + else: + i += 1 + + print("Element not found") + return 0 + + + +# Code for matrix input from user + +N = int(input("Enter the number of rows:")) + +# Initialize matrix +mat = [] +print("Enter the entries rowwise:") + +# For user input +for i in range(N): # A for loop for row entries + a = [] + for j in range(N): # A for loop for column entries + a.append(int(input())) + mat.append(a) + +# Input Element to be Search +Search = int(input("Enter the Element to Search:")) + +# Call the Function +search(mat,N,Search) \ No newline at end of file diff --git a/Mohammad Farukh/12 May 2020/Q3_12_05_2020 - Output.PNG b/Mohammad Farukh/12 May 2020/Q3_12_05_2020 - Output.PNG new file mode 100644 index 0000000..e73d046 Binary files /dev/null and b/Mohammad Farukh/12 May 2020/Q3_12_05_2020 - Output.PNG differ diff --git a/Mohammad Farukh/12 May 2020/Q3_12_05_2020.py b/Mohammad Farukh/12 May 2020/Q3_12_05_2020.py new file mode 100644 index 0000000..8449331 --- /dev/null +++ b/Mohammad Farukh/12 May 2020/Q3_12_05_2020.py @@ -0,0 +1,27 @@ +# Code for matrix input from user + +R = int(input("Enter the number of rows:")) +C = int(input("Enter the number of columns:")) + +# Initialize matrix +matrix = [] +print("Enter the entries rowwise:") + +# For user input +for i in range(R): # A for loop for row entries + a = [] + for j in range(C): # A for loop for column entries + a.append(int(input())) + matrix.append(a) +count =0 +sum = 0 + +#logic is Here +for i in range(R): + for j in range(C): + if ((matrix[j][i]) == 1): + count = count + 1 + if count % 2 == 1: + sum = sum + 1 + +print(sum) diff --git a/Mohammad Farukh/13 May 2020/Q1_13_05_2020 - Output.PNG b/Mohammad Farukh/13 May 2020/Q1_13_05_2020 - Output.PNG new file mode 100644 index 0000000..1af37b0 Binary files /dev/null and b/Mohammad Farukh/13 May 2020/Q1_13_05_2020 - Output.PNG differ diff --git a/Mohammad Farukh/13 May 2020/Q1_13_05_2020.cpp b/Mohammad Farukh/13 May 2020/Q1_13_05_2020.cpp new file mode 100644 index 0000000..d253709 --- /dev/null +++ b/Mohammad Farukh/13 May 2020/Q1_13_05_2020.cpp @@ -0,0 +1,18 @@ + +#include +using namespace std; + +// Area of triagle using : 1/2(h*b) +int Area(int height,int base){ + return (height*base)/2; +} +// Area of triagle using : 1/2(a+b+c) +int Area(int a, int b, int c){ + return (a+b+c)/2; +} +int main(){ + cout<<"Area of Triangle 1/2(h*b) : "< +using namespace std; +class height { + int meter,centimeter; + + public: + void Entry(){ + cout<< " Enter Meter : "; + cin>>meter; + cout<< " Enter Centimeter : "; + cin>>centimeter; + } + void show(){ + cout << "Meter:" <=100){ + temp.centimeter%=100; + temp.meter++; + } + return temp; + } + +}; + +int main(){ + + height H1,H2,H3; + H1.Entry(); + cout< +using namespace std; + +class date{ + int day; + int month; + int year; + + public: + void input(){ + cout<< " Enter Day : "; + cin>>day; + cout<< " Enter Month : "; + cin>>month; + cout<<"Enter Year : "; + cin>>year; + } + date operator +(date D){ + date temp; + temp.day = day + 1; + temp.month = month; + temp.year = year; + if(temp.day>30){ + temp.day =1; + temp.month++; + if(temp.month>12){ + temp.month =1; + temp.year = year+1; + } + + } + + return temp; + } + void show(){ + cout<<"=======> Increased Date <========"< +#include +using namespace std; +int run =0; + +class team{ + public : + + int run = 0; + int ball=0,input,count=0; + vector m1({-2,-1,0,1,2,3,4,5,6}); + + int SuperOver(){ + while(ball<6){ + cin>>input; + if(input == (-2)) + ball++; + else if(input == (-1)) + run++; + + else if(input == 0) + ball++; + + else if(input == (1)){ + run++; + ball++; + } + + else if(input == 2){ + run+=2; + ball++; + } + else if(input == 3){ + run+=3; + ball++; + } + + else if(input == 4){ + run+=4; + ball++; + } + else if(input == 5){ + run+=4; + ball++; + } + else if(input == 6){ + run+=6; + ball++; + } + + else + cout<<"Envalid Entry"< m1({-2,-1,0,1,2,3,4,5,6}); + team Team1 , Team2; + cout<<"Team1 :: Bowling and Team2 :: Batting "< +#include +#include +using namespace std; +float scanNum(char ch) { + int value; + value = ch; + return float(value-'0'); //return float from character +} +int isOperator(char ch) { + if(ch == '+'|| ch == '-'|| ch == '*'|| ch == '/' || ch == '^') + return 1; //character is an operator + return -1; //not an operator +} +int isOperand(char ch) { + if(ch >= '0' && ch <= '9') + return 1; //character is an operand + return -1; //not an operand +} +float operation(int a, int b, char op) { + //Perform operation + if(op == '+') + return b+a; + else if(op == '-') + return b-a; + else if(op == '*') + return b*a; + else if(op == '/') + return b/a; + else if(op == '^') + return pow(b,a); //find b^a + else + return INT_MIN; //return negative infinity +} +float postfixEval(string postfix) { + int a, b; + stack stk; + string::iterator it; + for(it=postfix.begin(); it!=postfix.end(); it++) { + //read elements and perform postfix evaluation + if(isOperator(*it) != -1) { + a = stk.top(); + stk.pop(); + b = stk.top(); + stk.pop(); + stk.push(operation(a, b, *it)); + }else if(isOperand(*it) > 0) { + stk.push(scanNum(*it)); + } + } + return stk.top(); +} +main() { + string post; + cout << "Input String / Expression "<>post; + cout << "The Output"< +using namespace std; + +bool isOperator(char c) +{ + return (!isalpha(c) && !isdigit(c)); +} + +int getPriority(char C) +{ + if (C == '-' || C == '+') + return 1; + else if (C == '*' || C == '/') + return 2; + else if (C == '^') + return 3; + return 0; +} + +string infixToPostfix(string infix) +{ + infix = '(' + infix + ')'; + int l = infix.size(); + stack char_stack; + string output; + + for (int i = 0; i < l; i++) { + + + if (isalpha(infix[i]) || isdigit(infix[i])) + output += infix[i]; + + else if (infix[i] == '(') + char_stack.push('('); + + else if (infix[i] == ')') { + + while (char_stack.top() != '(') { + output += char_stack.top(); + char_stack.pop(); + } + + // Remove '(' from the stack + char_stack.pop(); + } + + // Operator found + else { + + if (isOperator(char_stack.top())) { + while (getPriority(infix[i]) + <= getPriority(char_stack.top())) { + output += char_stack.top(); + char_stack.pop(); + } + + // Push current Operator on stack + char_stack.push(infix[i]); + } + } + } + return output; +} + +string infixToPrefix(string infix) +{ + + + int l = infix.size(); + + // Reverse infix + reverse(infix.begin(), infix.end()); + + // Replace ( with ) and vice versa + for (int i = 0; i < l; i++) { + + if (infix[i] == '(') { + infix[i] = ')'; + i++; + } + else if (infix[i] == ')') { + infix[i] = '('; + i++; + } + } + + string prefix = infixToPostfix(infix); + + // Reverse postfix + reverse(prefix.begin(), prefix.end()); + + return prefix; +} +// Main Fuction :) + +int main() +{ + string s; + cout<<"Enter A Expression : "; + cin>>s; + cout << infixToPrefix(s) << std::endl; + return 0; +} + diff --git a/Mohammad Farukh/17 May 2020/Q1_17_05_2020- Output.PNG b/Mohammad Farukh/17 May 2020/Q1_17_05_2020- Output.PNG new file mode 100644 index 0000000..2195f51 Binary files /dev/null and b/Mohammad Farukh/17 May 2020/Q1_17_05_2020- Output.PNG differ diff --git a/Mohammad Farukh/17 May 2020/Q1_17_05_2020.cpp b/Mohammad Farukh/17 May 2020/Q1_17_05_2020.cpp new file mode 100644 index 0000000..51f0dd9 --- /dev/null +++ b/Mohammad Farukh/17 May 2020/Q1_17_05_2020.cpp @@ -0,0 +1,33 @@ +/* +a=c +b=a +c=b + + + + +*/ +void swaping(int &a,int &b,int &c){ + a = a ^ b ^ c; // + b = a ^ b ^ c; + c = a ^ b ^ c; + a = a ^ b ^ c; + +} +#include +using namespace std; + +int main(){ + int a=10; + int b=20; + int c=30; + + cout<<"Before Swapping"< ("<binary1(y); + cout<<"Output Number : "< ("< +using namespace std; + +int Add(int x, int y) +{ + // Iterate till there is no carry + while (y != 0) + { + int carry = x & y; + x = x ^ y; + y = carry << 1; + } + return x; +} +int main() +{ + cout << "Addition ==> "<