-
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.
- Loading branch information
0 parents
commit 77e6b85
Showing
22 changed files
with
1,012 additions
and
0 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,2 @@ | ||
HARI_b@l | ||
microsoft office |
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,13 @@ | ||
#include<iostream> | ||
#include<vector> | ||
using namespace std; | ||
int main() | ||
{ | ||
vector<vector<int> > v(6,vector < int> (6,0)) ; | ||
for(int i =0 ; i<6;i++) | ||
{ | ||
for(int j=0 ;j<6 ; j++) | ||
cout<<v[i][j]<<" " ; | ||
cout<<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,54 @@ | ||
#include<iostream> | ||
#include<vector> | ||
using namespace std; | ||
|
||
int surface(vector<vector <int>> a , int h , int w) | ||
{ | ||
//top bottom surface | ||
long sum = 2*h*w ; | ||
int i,j; | ||
|
||
for(j=0 ; j<w ; j++) | ||
{ | ||
sum+=a[0][j]+a[h-1][j] ; | ||
for( i=0 ; i<h-1 ; i++) | ||
{ | ||
if(a[i][j]!=a[i+1][j]) | ||
{ | ||
sum+=abs(a[i][j]-a[i+1][j]) ; | ||
} | ||
} | ||
} | ||
|
||
for (i=0;i<h;i++) | ||
{ | ||
sum+=a[i][0]+a[i][w-1] ; | ||
for(j=0;j<w-1;j++) | ||
{ | ||
if(a[i][j]!=a[i][j+1]) | ||
{ | ||
sum+=abs(a[i][j]-a[i][j+1]) ; | ||
} | ||
} | ||
} | ||
|
||
return sum; | ||
} | ||
|
||
int main() | ||
{ | ||
int h,w; | ||
vector<vector <int>> a; | ||
cin>>h>>w ; | ||
for(int i=0 ; i<h ; i++) | ||
{ | ||
vector<int> b(w); | ||
for(int j=0 ; j<w ; j++) | ||
{ | ||
cin>>b[j]; | ||
} | ||
a.push_back(b); | ||
} | ||
cout<<surface(a,h,w); | ||
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,41 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
|
||
|
||
int reverse_int(int i) | ||
{ | ||
int r=0; | ||
while(i>0) | ||
{ | ||
r=r*10+i%10; | ||
i=i/10; | ||
} | ||
return r ; | ||
} | ||
// Complete the beautifulDays function below. | ||
int beautifulDays(int i, int j, int k) { | ||
int count=0 ; | ||
while(i<=j) | ||
{ | ||
if(abs(i-reverse_int(i))%k==0) | ||
count++ ; | ||
i++ ; | ||
} | ||
return count ; | ||
} | ||
|
||
int main() | ||
{ | ||
|
||
int i , j , k ; | ||
cout<<"Enter\n"; | ||
cin>>i>>j>>k ; | ||
int result = beautifulDays(i, j, k); | ||
|
||
cout<<result; | ||
|
||
|
||
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,22 @@ | ||
#include<bits/stdc++.h> | ||
|
||
using namespace std; | ||
int main() | ||
{ | ||
cout<<"Enter\n"; | ||
int q,x,y,z; | ||
cin>>q; | ||
while(q--) | ||
{ | ||
cin>>x; | ||
cin>>y; | ||
cin>>z; | ||
if(abs(x-z)==abs(y-z)) | ||
cout<<"Mouse C"; | ||
else if(abs(x-z)<abs(y-z)) | ||
cout<<"Cat A" ; | ||
else cout<<"Cat B"; | ||
} | ||
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,23 @@ | ||
#include<iostream> | ||
using namespace std ; | ||
int a(int i,int j) | ||
{ | ||
if(i==0) | ||
return j+1; | ||
else if(j==0) | ||
{ | ||
return a(i-1,1); | ||
} | ||
else | ||
{ | ||
return a(i-1,a(i,j-1)) ; | ||
} | ||
|
||
} | ||
int main() | ||
{ | ||
int n; | ||
cin>>n; | ||
for(int i=0;i<=n;i++) | ||
cout<<a(n,i)<<" "; | ||
} |
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,43 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
bool compare(vector <int> a , vector <int> b) | ||
{ | ||
return a[1]<b[1] ; | ||
} | ||
int main() | ||
{ | ||
vector<vector<int>> act ; | ||
int n ,i ,j,m=0; | ||
cout<<"Enter the no. of elements to be inserted\n" ; | ||
cin>>n; | ||
for(i=0 ;i<n ;i++) | ||
{ | ||
vector<int> b(2); | ||
cout<<"ENTER stating time and finishing time for activity "<<i+1<<endl; | ||
cin>>b[0] ; | ||
cin>>b[1] ; | ||
act.push_back(b); | ||
} | ||
sort( act.begin(),act.end(),compare); | ||
cout<<"ACTIVITY TABLE\n"; | ||
for(j=0 ;j<2 ;j++) | ||
{ | ||
for(i=0 ;i<n ;i++) | ||
{ | ||
cout<<act[i][j] << " "; | ||
} | ||
cout<<endl ; | ||
} | ||
vector<int> select; | ||
|
||
select.push_back(m) ; | ||
for(i=1 ;i<n ;i++){ | ||
if(act[i][0]>=act[m][1]){ | ||
m=i; | ||
select.push_back(m) ; | ||
} | ||
} | ||
cout<<"Selected activites are:\n"; | ||
for(int i=0;i<select.size();i++) | ||
cout<<select[i] ; | ||
} |
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,119 @@ | ||
#include <bits/stdc++.h> | ||
|
||
using namespace std; | ||
|
||
vector<string> split_string(string); | ||
|
||
// Complete the countApplesAndOranges function below. | ||
void countApplesAndOranges(int s, int t, int a, int b, vector<int> apples, vector<int> oranges) | ||
{ | ||
int app_count=0,ora_count=0; | ||
for(int i=0;i<apples.size();i++) | ||
{ | ||
if(apples[i]>=0) | ||
{ | ||
if(((s-a)<=apples[i]) && ((t-a)>=apples[i])) | ||
app_count++; | ||
} | ||
} | ||
for(int i=0;i<oranges.size();i++) | ||
{ | ||
if(oranges[i]<=0) | ||
{ | ||
if(((t-b)>=oranges[i])&&((s-b)<=oranges[i])) | ||
{ | ||
ora_count++; | ||
} | ||
} | ||
} | ||
cout<<app_count<<"\n"<<ora_count; | ||
} | ||
|
||
int main() | ||
{ | ||
string st_temp; | ||
getline(cin, st_temp); | ||
|
||
vector<string> st = split_string(st_temp); | ||
|
||
int s = stoi(st[0]); | ||
|
||
int t = stoi(st[1]); | ||
|
||
string ab_temp; | ||
getline(cin, ab_temp); | ||
|
||
vector<string> ab = split_string(ab_temp); | ||
|
||
int a = stoi(ab[0]); | ||
|
||
int b = stoi(ab[1]); | ||
|
||
string mn_temp; | ||
getline(cin, mn_temp); | ||
|
||
vector<string> mn = split_string(mn_temp); | ||
|
||
int m = stoi(mn[0]); | ||
|
||
int n = stoi(mn[1]); | ||
|
||
string apples_temp_temp; | ||
getline(cin, apples_temp_temp); | ||
|
||
vector<string> apples_temp = split_string(apples_temp_temp); | ||
|
||
vector<int> apples(m); | ||
|
||
for (int i = 0; i < m; i++) { | ||
int apples_item = stoi(apples_temp[i]); | ||
|
||
apples[i] = apples_item; | ||
} | ||
|
||
string oranges_temp_temp; | ||
getline(cin, oranges_temp_temp); | ||
|
||
vector<string> oranges_temp = split_string(oranges_temp_temp); | ||
|
||
vector<int> oranges(n); | ||
|
||
for (int i = 0; i < n; i++) { | ||
int oranges_item = stoi(oranges_temp[i]); | ||
|
||
oranges[i] = oranges_item; | ||
} | ||
|
||
countApplesAndOranges(s, t, a, b, apples, oranges); | ||
|
||
return 0; | ||
} | ||
|
||
vector<string> split_string(string input_string) { | ||
string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { | ||
return x == y and x == ' '; | ||
}); | ||
|
||
input_string.erase(new_end, input_string.end()); | ||
|
||
while (input_string[input_string.length() - 1] == ' ') { | ||
input_string.pop_back(); | ||
} | ||
|
||
vector<string> splits; | ||
char delimiter = ' '; | ||
|
||
size_t i = 0; | ||
size_t pos = input_string.find(delimiter); | ||
|
||
while (pos != string::npos) { | ||
splits.push_back(input_string.substr(i, pos - i)); | ||
|
||
i = pos + 1; | ||
pos = input_string.find(delimiter, i); | ||
} | ||
|
||
splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); | ||
|
||
return splits; | ||
} |
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,17 @@ | ||
#include<iostream> | ||
#include<cmath> | ||
using namespace std; | ||
int main() | ||
{ | ||
float d,e,i,n,l=0,guess=0; | ||
e=.01; | ||
i=0.01; | ||
cin>>n; | ||
|
||
while(( (pow(guess,3))-n)>=e && guess<=n) | ||
{ | ||
guess+=i; | ||
l++; | ||
} | ||
cout<<guess; | ||
} |
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,24 @@ | ||
#include<iostream> | ||
#include<cmath> | ||
using namespace std; | ||
int main() | ||
{ | ||
int n,r,x,l=0; | ||
cin>>n; | ||
x=n; | ||
while (x) | ||
{ | ||
l++; //no. of digit | ||
x = x/10; | ||
} | ||
int temp = n, sum = 0; | ||
while (temp) | ||
{ | ||
r = temp%10; | ||
sum += pow(r, l); | ||
temp = temp/10; | ||
} | ||
if(n==sum) | ||
cout<<"Armstrong number"; | ||
else cout<<"Not Armstrong"; | ||
} |
Oops, something went wrong.