Computer Science, asked by swethachowdary845, 10 months ago

Dora is so much interested in gardening and hence she plants more trees in her garden. She plants trees in a rectangular fashion with the order of rows and columns and numbers the trees in a row-wise order. She planted the mango tree only in the 1st row, 1st column and last column. So, given the tree number, your task is to find out whether the given tree is a mango tree or not? Now, write a program to check whether the given number denotes a mango tree or not.

Answers

Answered by noushin99882
35

Answer:

#include<iostream>

using namespace std;

int main()

{

 int a,b,c,t,t1;

 cin>>a>>b>>c;

 t=a*b;

 t1=t-b;

 if(c<=t1 ){cout<<"Yes";}

 

else{cout<<"No";}

}

Explanation:

Still one test case is failing..

Answered by NehaKari
1

Answer:

import java.util.*;

class MyClass {

public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);

int r = sc.nextInt();

int c = sc.nextInt();

int n = sc.nextInt();

 if(r*2 == n || r*(c-1) == n)

   System.out.println("Yes");

 else

   System.out.println("No");

}

}

Explanation:

We know that Dora planted the mango tree only in the 1st row, 1st column and last column. Given this information, we shall write the following program and run it to find out whether a given tree is a mango tree or not:

import java.util.*;

class MyClass {

public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);

int r = sc.nextInt();

int c = sc.nextInt();

int n = sc.nextInt();

 if(r*2 == n || r*(c-1) == n)

   System.out.println("Yes");

 else

   System.out.println("No");

}

}

#SPJ2

Similar questions