C/C++ :: Find Triangle In Array Of N Triangles Which Has Largest Area
Apr 6, 2015
How to find triangle in an array of n triangles which has the largest area?
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
typedef struct {
double x,y;
[Code] .....
View 14 Replies
ADVERTISEMENT
May 26, 2013
i have written a program to find area of triangle, but i meet some errors,
//******area of triangle******//
#include<iostream>
using namespace std;
[Code].....
View 1 Replies
View Related
Sep 29, 2013
Thing I want is find the largest sum down a triangle,(moving to adjacent numbers on the row below )there are many methods to go down.
75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
I wrote a program with a recursive() called finder. But it dose not work properly,at run time it becomes to a infinite status. How to detect the error at runtime. Here is the code.
#include<stdio.h>
void finder(int x,int y);
int tot;
[Code] ....
I think the error is the changing value of x after a round of for loop.
View 2 Replies
View Related
Jan 30, 2013
find inserted numbers, let say 10 numbers and find the largest and second largest number with their position in an array?
View 3 Replies
View Related
Nov 16, 2014
I was asked to build a small program to calculate the are of a Triangle but my code must have some problem.. />
#include "stdafx.h"
void main()
{
int a,b;
[Code]....
I get this errors:
-warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
-warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
View 4 Replies
View Related
Jun 10, 2013
I am currently learning "if statements" while doing a program that calculates the area of a triangle. My problem is that the result is always "0". I am pretty sure the problem lies within my math, but how I have set it up wrong.
I am using Heron's Formula. Here it is for reference:
area=sqrt(s(s-a)(s-b)(s-c)) where s=(a+b+c)/2
Code:
#include <stdio.h>
#include <math.h>
int main () {
float area, sideA, sideB, sideC, halfP;
[Code] ....
View 4 Replies
View Related
Nov 7, 2014
I need to calculate the area of a triangle using heron's formula. I wrote the code below and i need to modify it so that a user is required to keep entering the three side until he/she decides to stop. If the three sides entered make an invalid triangle, the user is required to re-enter the values until valid triangle is formed. Then the area is displayed.
#include <iostream>
#include <cmath>
using namespace std;
int main(){
double a,b,c=0;
double s,A=0;
[Code] .....
the screen output should like this:
Enter three sides of a triangle: 0 1 2 Error!
Re-enter three sides of a triangle: -1 1 2 Error!
Re-enter three sides of a triangle: 3 4 5 => 6
Continue (y/n)? y
Enter three sides of a triangle: 1 1 2 Error!
Re-enter three sides of a triangle: 6 8 10 => 24
Continue (y/n)? n
Done!
Please note that Continue (y/n)? only displayed after a valid triangle is formed. Otherwise, the user needs to re-enter sides until it's valid.
View 1 Replies
View Related
Jan 8, 2015
I have to write some cpp program which computes area of a triangle using cross product,we give 3 vertices as R2 and 3 edges as double.
I am beginning like this;
#include <iostream>
#include "R2.h"
#include <cmath>
using namespace std;
double area ( R2 *A,double *z)
[Code] .....
View 5 Replies
View Related
Aug 30, 2013
While finding the primes , I do not know how to make it into one array so that...
View 7 Replies
View Related
Apr 28, 2014
Write a program that uses two functions; one finds the largest number and second largest number; and second function finds the average. The data, comprising of 20 different temperature values, is available on a file.
View 1 Replies
View Related
May 13, 2014
im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.
void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];
[Code]...
View 5 Replies
View Related
Apr 1, 2013
Area of the room. Your task is to write a program that will find the area of room in a given square maze.
Note. Use recursion for solving this problem.
Input:
First line contains only one number N (3 <= N <= 10).The number that describes the size of the square maze.
On the next N lines maze itself is inputed ('.' - empty cell,'*' - wall).
And the last line contains two numbers - the row and column of the cell in the room those area you need to find.It is guaranteed that given cell is empty and that the maze is surrounded by walls on all sides.
Output:
Output only one number - total amount of empty cells in the selected room.
View 8 Replies
View Related
Feb 1, 2013
write a C++ program to find the area of a square, input the length of the side, and output your answer to the screen.
View 3 Replies
View Related
Jul 26, 2013
Its a code to find the largest number of a 3X3 matrix.The logic seems to be right........
Code:
#include<stdio.h>
main() {
int matrix[3][3],i,k,j,*a;
a=&matrix[0][0];
printf("Enter the elements");
for(i=0;i<=2;i++) {
[Code]....
View 7 Replies
View Related
Oct 18, 2014
Write a program that will find the smallest, largest and average of the values in a collection of N positive integer numbers.
View 12 Replies
View Related
Apr 19, 2013
I have a std::map<int, foo>
what's the ideal way to get an iterator to the item that has the largest key (int) smaller than a given value.
basically, the item before upper_bound(). I can use upper_bound() and then decrement, but it needs special cases for both end() and begin(), and in the case of end() I'm not sure how I get it to the last item in the map, afaik, we're not allowed to decrement end().
Code:
auto it = mymap.upper_bound(x);
if (it==mymap.begin()) // first item in the map is already too large. reject
NotFound();
else if (it==mymap.end())
[Code] .....
// here it points to largest item smaller than x.
I can iterate over the entire map and do a compare, but then I pretty much loose the benefit of the binary search.
View 2 Replies
View Related
Oct 4, 2013
I'm working on a silent auction program that will scan a file and find the highest from each group of bids, then have a running total of money made throughout the auction. I'm pretty sure the rest of my code works, i'm just getting stuck on finding the largest number from the line in the file, saving it, then moving to the next auction.
input file text (first number is num of auctions, after that it's num of bids, then the bids):
5 4 100 500 250 300 1 700 3 300 150 175 2 920 680 8 20 10 15 25 50 30 19 23
Sample Output
Auction 1 sold for $500.00!
Auction 2 sold for $700.00!
Auction 3 sold for $300.00!
Auction 4 sold for $920.00!
Auction 5 sold for $50.00!
The silent auction raised $2470.00 for charity!
Code:
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
[Code].....
View 4 Replies
View Related
Mar 6, 2015
How to find the largest and smallest number entered by a user. So far I'm able to add, find the average and count how many numbers are entered.
I'm just having trouble with find the max and min. I tried if statements and it breaks the program will it wont let me exit the while loop or the program will do a force close after entering a value.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
int maxNum=0, minNum=0, value, count=0, sum=0;
double average;
[Code] ....
View 4 Replies
View Related
Feb 27, 2013
I made the code that stores and prints 5 row by 5 column values but how to find the largest number from them.What should I do to find the largest number?If I use if-else then it would be very tedious but I think there is way out with for loop but still I can't frame the logic. Here is the code
Code:
#include<stdio.h>
main() {
int lnum[5][5];
int i,j;
for(i=0;i<=4;i++) {
[Code] .....
View 7 Replies
View Related
May 30, 2014
I seem to have reached a dead end in a program I am attempting to write.The purpose of the program is find the smallest, largest, and average values in a collection of N numbers. It needs to get the value of N before scanning each value in the collection of N numbers.I'm having trouble creating comparisons for each set. I have a feeling because of the way I structured my program, I'm unable to make a proper comparison. Maybe my approach was wrong as soon as I got to the for statement to loop N sets and N numbers.Here is my code so far:
Code:
#include <stdio.h>
int main (void)
{
int num_sets, num_of_integers;
int count, count2, set, sum = 0;
int num, avg;
}
[code]....
/* Here is where I would continue to attempt to make a comparison between sets to determine smallest to largest */
return 0;
View 5 Replies
View Related
Nov 16, 2013
I am writing this code, and I every time I run question A, no matter what numbers I put in, I get "larger = 0.
#include <iostream>
using namespace std;
int awesome ();
int best ();
int crazy ();
int main () {
char letter;
int smallestNumber;
int largestNumber;
[Code] .....
View 2 Replies
View Related
Oct 12, 2014
I want to find third largest character in ascii as alphanumeritic. The problem is i cannot use arrays. How can I find third largest number ? Have to I compare all chars with each other ?
void third_largest(){
char ch;
do{
scanf("%c",&ch);
}
while(ch!=' ');
}
The chars can be hold up to press space ...
View 1 Replies
View Related
May 25, 2014
Write a program that reads in a list of integers into an array with base type of int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.
For example, for the input
-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12
the output should be
N Count
4 2
3 3
2 2
1 4
-1 1
-12 4
Here's My code So far:
#include <iostream>
#include <fstream>
using namespace std;
const int SIZE = 50;
[Code]....
My Code outputs the numbers From Largest to Smallest according to given array, but I need to make it to output the numbers once(if its repeated)
View 2 Replies
View Related
Aug 16, 2014
how can i display a pascal triangle in forloop?
Here's my code.
#include<iostream>
using namespace std;
void print(int a[3][3])
[Code].....
View 1 Replies
View Related
Feb 16, 2015
i'm having trouble trying to make this code works .. the program must repeatedly asks user for the age of a person until user enters -1 ,, once he/she entered -1 the program calculates ( smallest value entered, largest value , and average )excluding -1 from calculation
i've been working on this for a weeks this is the best i could do.i know average must add all the entered values , not only smallest and largest but how can i do that here ?
Code:
#include<stdio.h>
int main(void)
{
int age ;
int v;
int counter;
int l=0;
int s=0;
int limit;
}
[code]....
View 13 Replies
View Related
Sep 26, 2013
question from chapter 11, qn 8 modern C programming by king
Write the following function: Code: int *find_largest(int a[], int n); When passed an array a of length n, the function will return a pointer to the array's largest element
Code:
#include <stdio.h>
int *find_largest(int a[], int n)
{
int i, x;
x = 0;
[Code].....
have traced the code line by line and it prints correctly up to line 31. However, when the program exits (line 35) , it goes to some other screen with very complex code and my output disappears.
Just to clarify: If I just run the code as is, there is no output. However, when I trace the code line by line, the output appears, but then disappears as the program exits My input was 1 2 3 4 5 6
View 11 Replies
View Related