- #include<stdio.h>
-
int maxi(int x,int y);
-
int buildtourn(int tourn[],int n);
-
int nextmax(int tourn[],int n);
-
-
int main()
-
{
-
int tourn[100],n,i;
-
printf("give n:");
-
scanf("%d",&n);
-
for(i=n;i<2*n-1;i++)
-
{printf("give the %d inputs",n);
-
scanf("%d",&tourn[i]);
-
}
-
printf("%d",nextmax(tourn[],n));
-
printf("maximum is %d",tourn[1]);
-
-
return 0;
-
}
-
int buildtourn(int tourn[],int n)
-
{int i;
-
for(i=2*n-1;i>1;i-=2)
-
tourn[i/2]=maxi(tourn[i],tourn[i+1]);
-
return 0;
-
}
-
int nextmax(int tourn[],int n)
-
{int i=2,next;
-
next=maxi(tourn[2],tourn[3]);
-
while(i<=2*n-1)
-
{
-
if(tourn[i]>tourn[i+1])
-
{next=maxi(tourn[i],next);
-
i=2*i;
-
}
-
else
-
{next=maxi(tourn[i+1],next);
-
i=2*(i+1);} }
-
return(next);}
1 2659
your error on line 15,
if you want to pass the pointer to
function then this is a wrong way, try this -
printf("%d",nextmax(&tourn[0],n))
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jeremy Yallop |
last post by:
Looking over some code I came across a line like this
if isalnum((unsigned char)c) {
which was accepted by the compiler without complaint. Should the
compiler have issued a diagnostic in this...
|
by: Rody Reulen |
last post by:
I made an console application with Visual Basic .net. Visual Basic will
automatically create the sub procedure main for you. I try to convert the
main procedure to a function.
During the...
|
by: joe10001 |
last post by:
Hi all,
I just installed CRELoaded (oscommerce fork) on my server and all work
fine except that I have a little message at the bottom of the main page
:
Fatal error: main() : Security alert:...
|
by: Hexer |
last post by:
Hi and good day to all...I am new to the C language and whenever I tried to run the program I made, it won't because it says it has an "expression syntax error in function main"..what I don't get is...
|
by: huggsy |
last post by:
I started using C just today and I am having a problem with strrev() function.
Here are my codes:
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
|
by: ANURAGBAJPAI |
last post by:
Please tell me what is the purpose of void in function main.
|
by: ehab mohamed |
last post by:
When i try to run this program it give me a message that Lvalue required in function main. What is the cause?
|
by: pecca |
last post by:
this is sample of my program
#include<iostream.h>
#include<conio.h>
#define n 5
int total(int number);
int average(int average, int total);
void min_max(int number,int &min,int &max);
void...
|
by: DavidSS |
last post by:
Okay, I have a problem.
I just started programming, and made my first "calculator" I then started making it more advanced, so it wouldn't crash if you tried to divide by 0.
Then I wanted to make...
|
by: ehab mohamed |
last post by:
#include<stdio.h>
int main()
{
typedef struct {
char name;
int salary;
}me;
me a;
a.name="ehab";
a.salary=5789;
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |