Skip to content

Commit b055409

Browse files
authored
Merge pull request #356 from saurabh22111999/j
added solution (Alternative Square Pattern)
2 parents 1f1916a + 2b5bda0 commit b055409

File tree

10 files changed

+214
-0
lines changed

10 files changed

+214
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Alternative Square Pattern Problem Code: SQALPAT
2+
Add problem to Todo list
3+
4+
You're given a number N. Print the first N lines of the below-given pattern.
5+
6+
1 2 3 4 5
7+
10 9 8 7 6
8+
11 12 13 14 15
9+
20 19 18 17 16
10+
21 22 23 24 25
11+
30 29 28 27 26
12+
Input:
13+
First-line will contain the number N.
14+
Output:
15+
Print the first N lines of the given pattern.
16+
17+
Constraints
18+
1≤N≤200
19+
Sample Input 1:
20+
4
21+
Sample Output 1:
22+
1 2 3 4 5
23+
10 9 8 7 6
24+
11 12 13 14 15
25+
20 19 18 17 16
26+
Sample Input 2:
27+
2
28+
Sample Output 2:
29+
1 2 3 4 5
30+
10 9 8 7 6
31+
EXPLANATION:
32+
In the first example, we'll print the first 4 lines of the given pattern.
33+
In the second example, we'll print the first 2 lines of the given pattern.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int n;
6+
cin>>n;
7+
int sumi = 0, sumj = 10;
8+
for(int i=1; i<=n; i++){
9+
if(i%2!=0){
10+
for(int j=sumi+1; j<=sumi+5; j++){
11+
cout<<j<<" ";
12+
}
13+
cout<<endl;
14+
sumi = sumi + 10;
15+
}else{
16+
for(int j=sumj; j>=sumj-4; j--){
17+
cout<<j<<" ";
18+
}
19+
cout<<endl;
20+
sumj = sumj + 10;
21+
}
22+
}
23+
return 0;
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Sum Is Everywhere Problem Code: SUMEVOD
2+
Add problem to Todo list
3+
4+
You are given a number N and find the sum of the first N odd and even numbers in a line separated by space. All even and odd numbers should be greater than 0.
5+
6+
Input:
7+
First-line will contain the number N.
8+
Output:
9+
Print the sum of the first N odd and even numbers in a line separated by space.
10+
11+
Constraints
12+
1≤N≤106
13+
Sample Input 1:
14+
4
15+
Sample Output 1:
16+
16 20
17+
Sample Input 2:
18+
1
19+
Sample Output 2:
20+
1 2
21+
EXPLANATION:
22+
In the first example, (1 + 3 + 5 + 7) = 16 and (2 + 4 + 6 + 8) = 20.
23+
In the second example, only one odd that is 1 and only one even that is 2.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
#define ll long long
3+
using namespace std;
4+
5+
int main() {
6+
// your code goes here
7+
ll n,even,odd;
8+
9+
cin>>n;
10+
even = n(n+1);
11+
odd = nn;
12+
cout<<odd<<" "<<even;
13+
14+
return 0;
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Triangle Everywhere Problem Code: EXTRICHK
2+
Add problem to Todo list
3+
4+
You're given the length of three sides a, b, and c respectively. Now If these three sides can form an Equilateral Triangle then print 1, if these three sides can form an Isosceles Triangle then print 2, if these three sides can form a Scalene Triangle then print 3, otherwise print −1.
5+
6+
Input:
7+
First-line will contain three numbers a, b, and c separated by space.
8+
Output:
9+
Print the answer in a new line.
10+
11+
Constraints
12+
1≤a,b,c≤103
13+
Sample Input 1:
14+
2 4 3
15+
Sample Output 1:
16+
3
17+
Sample Input 2:
18+
4 4 4
19+
Sample Output 2:
20+
1
21+
Sample Input 3:
22+
4 4 9
23+
Sample Output 3:
24+
-1
25+
EXPLANATION:
26+
In the first example, (2, 4, 3) will form a Scalene Triangle.
27+
In the second example, (4, 4, 4) will form an Equilateral Triangle.
28+
In the third example, (4, 4, 9) will not form a triangle.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int a, b, c;
7+
cin >> a >> b >> c;
8+
if (a + b > c && b + c > a && c + a > b)
9+
{
10+
if (a == b && b == c)
11+
cout << "1";
12+
else if (a == b b == c c == a)
13+
cout << "2";
14+
else
15+
cout << "3";
16+
}
17+
else
18+
cout << "-1";
19+
return 0;
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Triangle With Angle Problem Code: ANGTRICH
2+
Add problem to Todo list
3+
4+
You're given the three angles a, b, and c respectively. Now check if these three angles can form a valid triangle with an area greater than 0 or not. Print "YES"(without quotes) if it can form a valid triangle with an area greater than 0, otherwise print "NO" (without quotes).
5+
6+
Input:
7+
First-line will contain three numbers a, b, and c separated by space.
8+
Output:
9+
Print "YES"(without quotes) if these sides can form a valid triangle, otherwise print "NO" (without quotes).
10+
11+
Constraints
12+
0≤a,b,c≤180
13+
Sample Input 1:
14+
20 40 120
15+
Sample Output 1:
16+
YES
17+
Sample Input 2:
18+
100 18 42
19+
Sample Output 2:
20+
NO
21+
EXPLANATION:
22+
In the first example, angles set (20, 40, 120) can form a triangle with an area greater than 0.
23+
In the second example, angles set (100, 18, 42) will never form a valid triangle.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
int a,b,c;
7+
cin>>a>>b>>c;
8+
if(a+b+c==180&& a>0 && b>0 && c>0){
9+
cout<<"YES";
10+
}
11+
else{
12+
cout<<"NO";
13+
}
14+
return 0;
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
You're given the length of three sides a, b, and c respectively. Now check if these three sides can form a triangle or not. Print "YES"(without quotes) if it can form a valid triangle with an area greater than 0, otherwise print "NO" (without quotes).
2+
3+
Input:
4+
First-line will contain three numbers a, b, and c separated by space.
5+
Output:
6+
Print "YES"(without quotes) if these sides can form a valid triangle, otherwise print "NO" (without quotes).
7+
8+
Constraints
9+
1≤a,b,c≤106
10+
Sample Input 1:
11+
2 4 3
12+
Sample Output 1:
13+
YES
14+
Sample Input 2:
15+
1 1 4
16+
Sample Output 2:
17+
NO
18+
EXPLANATION:
19+
In the first example, (2, 4, 3) can form a triangle with an area greater than 0.
20+
In the second example, (1, 1, 4) will never form a valid triangle.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int a, b, c;
7+
cin >> a >> b >> c;
8+
if (a + b < c a + c < b b + c < a)
9+
cout << "NO";
10+
else
11+
cout << "YES";
12+
return 0;
13+
}

0 commit comments

Comments
 (0)