Skip to content

Commit f312f2b

Browse files
Merge pull request #159 from Sahil-git005/Problems
daily cpp code by Sahil
2 parents 26f3ec3 + ce705e9 commit f312f2b

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

day-001 Sahil.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<iostream>
2+
#include<cmath>
3+
using namespace std;
4+
int main(){
5+
int a,b,c,N;
6+
cout<<"Enter the value of a,b,c : ";
7+
cin>>a>>b>>c;
8+
9+
N = 2* abs(a-b); //circle ka size kyuki a or b aamne samne h toh toh unke bich m aadhe element hi honge circle ke toh unka double sare element honge!
10+
11+
//N need to be even and non zero if not even no condition will we followed
12+
13+
if(N%2==0 && N!=0 && c<=N){
14+
//c N se choti hi honi chahiye
15+
16+
// c ke opposite wala num bhi N/2 dur hi hona chahiye kyuki even h toh symmetry follow hogi!
17+
//cout<<"opposite of c is "<<c+N/2<<endl;
18+
19+
// ab agr input a=1,b=3,c=4 kr rhe h toh output 6 aarha h jb ki N toh 4 hi h or output 2 aana chahiye jo ki ' c - N/2 '
20+
21+
//toh fir kuch case or bnenge!!
22+
if(c+N/2>=N){
23+
cout<<"opposite of c is "<<c-N/2<<endl;
24+
} else{
25+
cout<<"opposite of c is "<<c+N/2<<endl;
26+
}
27+
}
28+
29+
else{
30+
cout<<"-1\n";
31+
}
32+
return 0;
33+
}

0 commit comments

Comments
 (0)