What change shuld i make to my code so that the largest value stored
in a is displayed first, followed by the
second largest value, then the third, and so forth (i.e. the cout at
Line 35 displays the values stored
in a in descending order)?
13 void f1(int a[]) {
14 int x, y;
15 int t;
16 for(x = 1; x < 10; x++) {
17 if(a[x] = a[x - 1]) {
18 t = a[x];
19 y = x;
20 do {
21 a[y] = a[y - 1];
22 y--;
23 } while (y 0 && a[y - 1] t);
24 a[y] = t;
25 }
26 }
27 return;
28 }
29 int main (int argc, char **argv)
30 {
31 int a[10];
32 char reply;
33 for (int i = 0; i < 10; i++) a[i] = 100 - i;
34 f1(a);
35 for (int i = 0; i < 10; i++) cout << i << ". " << a[i] << endl; 2 1244 de********@gmai l.com wrote:
What change shuld i make to my code so that the largest value stored
in a is displayed first, followed by the
second largest value, then the third, and so forth (i.e. the cout at
Line 35 displays the values stored
in a in descending order)?
Come on, at least make an attempt. This isn't a homework group.
>
13 void f1(int a[]) {
14 int x, y;
15 int t;
16 for(x = 1; x < 10; x++) {
17 if(a[x] = a[x - 1]) {
18 t = a[x];
19 y = x;
20 do {
21 a[y] = a[y - 1];
22 y--;
23 } while (y 0 && a[y - 1] t);
24 a[y] = t;
25 }
26 }
27 return;
28 }
29 int main (int argc, char **argv)
30 {
31 int a[10];
32 char reply;
33 for (int i = 0; i < 10; i++) a[i] = 100 - i;
34 f1(a);
35 for (int i = 0; i < 10; i++) cout << i << ". " << a[i] << endl;
--
Ian Collins.
On Mar 22, 4:32 pm, Ian Collins <ian-n...@hotmail.co mwrote:
devoreb...@gmai l.com wrote:
What change shuld i make to my code so that the largest value stored
in a is displayed first, followed by the
second largest value, then the third, and so forth (i.e. the cout at
Line 35 displays the values stored
in a in descending order)?
Come on, at least make an attempt. This isn't a homework group.
13 void f1(int a[]) {
14 int x, y;
15 int t;
16 for(x = 1; x < 10; x++) {
17 if(a[x] = a[x - 1]) {
18 t = a[x];
19 y = x;
20 do {
21 a[y] = a[y - 1];
22 y--;
23 } while (y 0 && a[y - 1] t);
24 a[y] = t;
25 }
26 }
27 return;
28 }
29 int main (int argc, char **argv)
30 {
31 int a[10];
32 char reply;
33 for (int i = 0; i < 10; i++) a[i] = 100 - i;
34 f1(a);
35 for (int i = 0; i < 10; i++) cout << i << ". " << a[i] << endl;
--
Ian Collins.- Hide quoted text -
- Show quoted text -
this is the first question i posted on the forum man what are you
talking about. I am trying to learn something i dont ask you to give
the answer but at least you can tell me what to o to figure out the
problem right? if you dont want to do it, it is cool too; but i am not
trying to get my homeworks done... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hank |
last post by:
Hi,
does anyone know how to change the foreground color of the command
prompt through python?
For example if i was printing out an error message, I would like it to
be red where the normal text color is white.
Thanks
|
by: M Wells |
last post by:
Hi All,
Just wondering how you go about changing the value of a session cookie
via javascript?
I have a PHP page that sets a session cookie when it first loads. I'd
like to be able to change the value of that session cookie in response
to a button click in a form, without resubmitting the page.
For some reason, the following doesn't seem to work:
|
by: Wolfgang |
last post by:
Dear all,
I've a lot of buttons named button1..button100 and want to change some of there propertys.
Maintaining the overview I'm looking for a possibility for something like:
System::Windows::Forms::Button * Wolfgang;
for (i=1;i<100;i++)
{
Wolfgang = ???;
|
by: GaryDean |
last post by:
In the original post I failed so indicate that I am using framework
1.1.......
I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...
<body MS_POSITIONING="GridLayout" runat="server" id="bg">
then we could do the following in our codebehind file....
|
by: saurabh |
last post by:
Can anybody tell me how to change the value of an html control from the
c#....
eg i hv one asp.net radio button control and one html hidden
variable...
so on page load in case the radio button is checked i want to set this
hidden variable to 1 else 0...
I am not getting what to write in Page_Load(object sender,
System.EventArgs e) function to change the value of this html
variable...
| |
by: Mikael Olofsson |
last post by:
Hi!
This is in Python 2.3.4 under WinXP.
I have a situation where I think changing the behaviour of a namespace
would be very nice. The goal is to be able to run a python file from
another in a separate namespace in such a way that a NameError is not
raised if a non-existing variable is used in the file. The file that I
want to run is taken out of context, and some needed variables may be
missing that are normally there when used in...
|
by: Bonzol |
last post by:
Vb.net 2003, Web application
Hey all!
Just a quick question.
I have a site which allows users the ability to upload files by the
HTML brows button control.
My question is if a user submits a file,, and every file they submit I
want my code to change the name of it.. So say the user submits
|
by: Hennie Coertze |
last post by:
Good day,
My knowledge of XML is next to none and I only have one XSL code to use.
I also assume I may be using incorrect jargon and hope you will
understand what I need.
I have an XSL style sheet to convert the XML flat file. I need to
change the style sheet so it groups certain data together under one
heading. I need to be able to do this as the system I upload the file
to do not accept the information as presented and continuously...
|
by: David |
last post by:
With a non-server app there is one instance of the program running and one
user 'using' it at a time. With this scenario I'm pretty comfortable with
variable scope and lifetime. With a server app there is one instance of the
program running but several simultaneous clients connecting to and 'using'
it. When I think about this I'm wondering what this may add to what needs to
be considered for scope and lifetime... is a scenario created where...
|
by: viceyo |
last post by:
Hi!
I'm new to Javascript and I'm trying to write a script in which I need to use diferent variable names. The names are used from here:
<img border="0" alt="Visit W3Schools!" src="052407-ektron-pmsa-authentication.gif" name="b1" width="26" ...
I have several images which go from b1 to b5 but I want to be able to change that. For example, to add or remove images with almost no code changes.
I use a javascript to change the atributes...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |