-
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 07fc555
Showing
12 changed files
with
334 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,50 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int n; | ||
cin>>n; | ||
|
||
for(int i = 1; i <=n; i++) { | ||
for(int j = 1; j <= i; j++){ | ||
cout<<"*"; | ||
} | ||
|
||
int spaces = 2*n - 2*i; | ||
|
||
for(int j = 1; j <= spaces; j++){ | ||
cout<<" "; | ||
} | ||
|
||
|
||
for(int j = 1; j <= i; j++){ | ||
cout<<"*"; | ||
} | ||
|
||
cout<<endl; | ||
} | ||
|
||
for(int i = n; i >= 1 ; i--) { | ||
for(int j = 1; j <= i; j++){ | ||
cout<<"*"; | ||
} | ||
|
||
int spaces = 2*n - 2*i; | ||
|
||
for(int j = 1; j <= spaces; j++){ | ||
cout<<" "; | ||
} | ||
|
||
|
||
for(int j = 1; j <= i; j++){ | ||
cout<<"*"; | ||
} | ||
|
||
cout<<endl; | ||
} | ||
|
||
cout<<endl; | ||
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,33 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() { | ||
|
||
string str, str1 = ""; | ||
|
||
cin>>str; | ||
|
||
multiset<char> vowels = {'a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U', 'y', 'Y'}; | ||
|
||
for(auto it = str.begin(); it != str.end(); it++) { | ||
|
||
if(vowels.find(*it) != vowels.end()){ | ||
continue; | ||
}else { | ||
if(*it >= 65 && *it < 91) { | ||
*it += 32; | ||
} | ||
str1 = str1 + "." + *it; | ||
} | ||
} | ||
cout<<str1; | ||
|
||
// Solution 2 | ||
// char c; | ||
|
||
// while(cin>>c) { | ||
// if(!strchr("aeiouyAEIOUY", c)) cout<<"."<<(char)tolower(c); | ||
// } | ||
|
||
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> | ||
#include<string> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int n, len; | ||
string s[100]; | ||
|
||
cin>>n; | ||
|
||
for (int i = 0; i < n; i++) { | ||
cin>>s[i]; | ||
} | ||
|
||
for (int i = 0; i < n; i++) { | ||
len = s[i].length(); | ||
if(len > 10 ) cout<<s[i][0]<<len - 2<<s[i][len - 1]<<"\n"; | ||
else cout<<s[i]<<"\n"; | ||
} | ||
|
||
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<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
long long int n; | ||
int k; | ||
cin>>n>>k; | ||
|
||
while(k--) { | ||
if(n%10 > 0) { | ||
--n; | ||
}else { | ||
n /= 10; | ||
} | ||
} | ||
|
||
cout<<n; | ||
|
||
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,18 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int w; | ||
|
||
cin>>w; | ||
|
||
if(w % 2 == 0 && w > 3) { | ||
cout<<"YES"; | ||
} else { | ||
cout<<"NO"; | ||
} | ||
|
||
|
||
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,21 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int n; | ||
int counter = 0; | ||
|
||
cin>>n; | ||
|
||
for(int i = 0; i < n; i++) { | ||
for(int j = 0; j <= i; j++) { | ||
cout<<++counter; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
cout<<endl; | ||
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,20 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int n; | ||
|
||
cin>>n; | ||
|
||
for(int i = 0; i < n; i++) { | ||
for(int j = 0; j <= i; j++) { | ||
cout<<i+1; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
cout<<endl; | ||
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,24 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int n; | ||
|
||
cin>>n; | ||
|
||
for(int i = 0; i < n; i++) { | ||
for(int j = 0; j < n; j++) { | ||
if(j <= ((n-1) - (i + 1)) ){ | ||
cout<<" "; | ||
}else { | ||
cout<<'*'; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
|
||
cout<<endl; | ||
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,24 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int row, col; | ||
|
||
cin>>row>>col; | ||
|
||
for(int i = 0; i < row; i++) { | ||
for(int j = 0; j < col; j++) { | ||
if(i == 0 || j == 0 || i == (row - 1) || j == (col - 1) ) { | ||
cout<<'*'; | ||
}else { | ||
cout<<" "; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
|
||
cout<<endl; | ||
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,20 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
|
||
int n; | ||
|
||
cin>>n; | ||
|
||
for(int i = n - 1; i >= 0; i--) { | ||
for(int j = i; j >= 0; j--) { | ||
cout<<'*'; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
cout<<endl; | ||
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,61 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
//-------------------------------------------------------------- Solution 1 | ||
|
||
// vector<int> findErrorNums(vector<int>& nums) { | ||
// vector<int> arr(nums.size() + 1, 0); | ||
// vector<int> res(2,0); | ||
|
||
// for(auto it: nums) { | ||
// arr[it]++; | ||
// } | ||
|
||
// for(auto it = arr.begin() + 1; it != arr.end(); it++) { | ||
// if(*it == 2) { | ||
// res[0] = it - arr.begin(); | ||
// } | ||
// if(*it == 0) { | ||
// res[1] = it - arr.begin(); | ||
// } | ||
// } | ||
|
||
// return res; | ||
// } | ||
|
||
//-------------------------------------------------------------- Solution 2 | ||
vector<int> findErrorNums(vector<int>& nums) { | ||
int len = nums.size(); | ||
int sum = ((len) * (len + 1)) / 2, | ||
sum_sq = (len * (len + 1) * (2*len + 1) ) / 6; | ||
vector<int> res(2,0); | ||
|
||
for(auto it: nums) { | ||
sum -= it; | ||
sum_sq -= it*it; | ||
} | ||
|
||
res[1] = (sum_sq/sum + sum) / 2; | ||
res[0] = res[1] - sum; | ||
|
||
return res; | ||
} | ||
|
||
int main() { | ||
vector<int> nums; | ||
int x; | ||
|
||
while(cin>>x){ | ||
nums.push_back(x); | ||
} | ||
|
||
vector<int> res; | ||
|
||
res = findErrorNums(nums); | ||
|
||
for(auto it: res) { | ||
cout<<it<<","; | ||
} | ||
|
||
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,18 @@ | ||
#include<iostream> | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
int row, cols; | ||
|
||
cin>>row>>cols; | ||
|
||
for(int i = 0; i < row; i++) { | ||
for(int j = 0; j < cols; j++){ | ||
cout<<'*'; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
return 0; | ||
} |