Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/ #include <stdio.h> int main() { int a[4],b,c,d,e,f, g; for(b=0; b<4; b++) scanf("%d", &a[b]); for(b=0;b<4;b++) { for(c=b+1; c<4; c++) { if(a[c]<a[b]) { e=a[b]; a[b]=a[c]; a[c]=e; } } } g=a[1]+a[2]; f=a[0]+a[1]; if(a[3]<g || a[2]<f) printf("S\n"); else printf("N\n"); return 0; }
logic bujina
ReplyDeleteekhane ki kora hoise??
ascending order এ প্রথমে sort করা হইছে। তারপর প্রথম আর দ্বিতীয়টার যোগফল রাখা হইছে f এ। দ্বিতীয় আর তৃতীয়টার যোগফল রাখা হইছে g এ। চতুর্থটার মান যদি g থেকে ছোট হয় অথবা তৃতীয়টার মান যদি f থেকে ছোট হয় তখন S, নাইলে N।
Deleteascending order e sort korar dorkar ki? r sort kora chara kno thik vabe kaj korbe na??
DeleteGreat coding.Good job.
ReplyDeleteThank You Sir!!
DeleteMy pleasure..........!!!
:)
thanks................
ReplyDeletethanks vaiya,
ReplyDeletebest logic,
#include
ReplyDeleteint main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if (a+b>c && b+c>a && c+a>b){
printf("S\n");
}
else if (a+b>d && a+d>b && b+d>a){
printf("S\n");
}
else if (b+c>a && c+a>b && a+b>c){
printf("S\n");
}
else if (b+c>d && b+d>c && c+d>b){
printf("S\n");
}
else {
printf("N\n");
}
return 0;
}
/*Whats the problem here?*/
i commented this and it shows "wrong answer(10%)"
Delete#include
ReplyDeleteint main()
{
int a,b,c,d,i,max;
char ch;
while(scanf("%d",&a)!=EOF){
scanf("%d %d %d",&b,&c,&d);
if(a>b&&a>c&&a>d)max=a;
else if(b>a&&b>c&&b>d)max=b;
else if(c>a&&c>b&&c>d)max=c;
else max=d;
for(i=0;i<4;i++){
a=b;
b=c;
c=a;
if(a+b>max){
ch='S';
break;
}
else{
ch='N';
}
}
printf("%c\n",ch);
}
return 0;
}
ei code ta te ki bhul hoise bhaia.....
#include
ReplyDeleteusing namespace std;
int main()
{
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a>b && a>c && a>d){
if(b+c>=a || c+d>=a || b+d>=a){
printf("S\n");
}
else{
printf("N\n");
}
}
else if(b>a && b>c &&b>d){
if(a+c>=b || c+d>=b || a+d>=b){
printf("S\n");
}
else{
printf("N\n");
}
}
else if(c>b && c>a && c>d){
if(b+a>=c || a+d>=c || b+d>=c){
printf("S\n");
}
else{
printf("N\n");
}
}
else if(d>a && d>b && d>c){
if(b+c>=d || c+a>=d || b+a>=d){
printf("S\n");
}
else{
printf("N\n");
}
}
return 0;
}
akane 5% error dekanor karon ta jante pari ki?