473,659 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MAX value of a subsequence sum

i write a program about finding the max value of a subseqence in a
given sequence. i write but i finf lots of syntax mistakes and i
can't do them in correct. please help me.

Thanks;
Begum

here is the program

#include <iostream>
#include <conio.h>
#include <iomanip.h>
#pragma hdrstop
template <class someType>
class Sum
{
private:
someType arr[100];
public:
void add();
void get_sequence();
};
template <class someType>
void Sum<sumType>::a dd()
{
int i;
cout<<"****PLEA SE GIVE A SUBSEQUENCE WHICH IS TO FIND THE MAX.
VALUE ****\n"<<endl;
cin>>"%d",&d>>e ndl;
}
template <class someType>
void Sum<sumType>::g et_sequence()
{
int maxSum=0;
int thisSum=0;
int j;
for (j=0; j<101; j++)
{
thisSum +=a[j];
if (thisSum maxSum)
{
maxSum = thisSum;
}
else if (thisSum < 0)
{
thisSum=0;
}
return maxSum;
}
}
void main ()
{
void add();
void get_sequence();
}

Oct 9 '06 #1
2 2005

begum wrote in message
<11************ *********@b28g2 000cwb.googlegr oups.com>...
i write a program about finding the max value of a subseqence in a
given sequence. i write but i finf lots of syntax mistakes and i
can't do them in correct. please help me.
Thanks;
Begum

here is the program

#include <iostream>
#include <conio.h>
[ from a note in MinGW ]
/*
* conio.h
<snip copyright>
* Low level console I/O functions. Pretty please try to use the ANSI
* standard ones if you are writing new code.
*/
>#include <iomanip.h>
You probably mean <iomanip>.
>#pragma hdrstop
Compiler specific. (?).
>template <class someTypeclass Sum{
private:
someType arr[100];
public:
void add();
void get_sequence();
};
>template <class someType>
void Sum<sumType>::a dd(){
int i;
cout<<"****PLEA SE GIVE A SUBSEQUENCE WHICH IS TO FIND THE MAX.
VALUE ****\n"<<endl;
cin>>"%d",&d>>e ndl;
???? What the....?
You can't input to "%d" !!
You can't input to endl !!
[ You can't just mix/replace scanf syntax with iostreams. ]

Try:
cin >i;
}
template <class someType>
void Sum<sumType>::g et_sequence(){
int maxSum=0;
int thisSum=0;
// int j;

Unused except in 'for()', so, why don't you put it in the 'for()'?

// for (j=0; j<101; j++){
for (int j(0); j<101; ++j){
thisSum +=a[j];
There is NO 'a' anywhere!! Did you mean the 'arr[]' in your class?
if( thisSum maxSum ){
maxSum = thisSum;
} // if(>)
else if( thisSum < 0 ){
thisSum=0;
} // else if(<)
return maxSum;
Sure you want to 'return' from inside your loop?
} // for(j)
>} // Sum<sumType>::g et_sequence() end
>void main (){
Ahhh, I see now!! You are using code from the early 1980s!!

int main (){ // main() *always* returns an int!!

// void add();
// void get_sequence();
// [ those just declare some functions inside main. (and never define
them!) ]

Sum<intsum;

sum.add();
sum.get_sequenc e();

return 0;
}
Fix all that and try again. OK?
[ I assume you'll have new questions. ]
--
Bob R
POVrookie
Oct 9 '06 #2
"begum" <be*******@gmai l.comwrote:
i write a program about finding the max value of a subseqence in a
given sequence. i write but i finf lots of syntax mistakes and i
can't do them in correct. please help me.
Note the first error listed and the line number:

error: 'sumType' was not declared in this scope

points to:
template <class someType>
void Sum<sumType>::a dd() <---- points to here

Why do you think the compiler is telling you that 'sumType' is not
declared? (Meaning the compiler doesn't know what a 'sumType' is.

It took me longer than I'd care to admit to figure this one out. :-)

--
There are two things that simply cannot be doubted, logic and perception.
Doubt those, and you no longer*have anyone to discuss your doubts with,
nor any ability to discuss them.
Oct 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14140
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10." The PERL code is as follows:
3
18211
by: otto | last post by:
i need to read a variable in a javascript and translate it to a form in html the javascript variable is: <SCRIPT LANGUAGE='JavaScript'>RF2N('Total');</script> and i need to put that variable as the value in this line <input type="hidden" name="AMT" value="**">
3
11932
by: Eric Chang | last post by:
I was working on this simple form with radio boxes. And when I click on one of the radio box, it tell me the value is "undefined" Why is that ? I did defined the value of each radio box: <input type=radio name='Usetax' value='basic' onClick='document.myform.amount.value=document.myform.Usetax.value'> <input type=radio name='Usetax' value='no' onClick='document.myform.amount.value=document.myform.Usetax.value'> <input type=radio...
16
11480
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not an object... the function is like so: function calc_total() { var x,i,base,margin,total,newmargin,newtotal; base = document.frmKitAmount.txtTotalKitValue.value; margin = document.frmKitAmount.margin.value/100;
4
3011
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email User1@here.whatever and User4@here.whatever but if "Loaded" is chosen it needs to email User2@here.whatever and User3@here.whatever, etc, etc... I'm aware that the only thing that really needs to change is the "Mail.AddAddress" line (at least...
7
5072
by: matthew_carver | last post by:
Hello, I have an ASP page that loops through a SQL Server 2000 table, then downloads an Excel sheet the users can save, etc. Works fine, except, I see that in one particular "comments" field the Excel sheet returns a #VALUE! error in the cell when there is a large amount of text. I've looked through the MSKB, MSDN and many ng posts to see if there is a workaround or solution to this, including looking at the xlWorksheet properties. Is...
13
9607
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
1
2900
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value is chosen from the script generated drop down list in the
12
2333
by: begum | last post by:
in this program they want me to find the max value of a subsequence in a given sequnce of numbers(the sequence is represented by an array) by using templates and pointers.also i must write a main in order to instantiate differnt objects of my class. in this program i don't want to find the sum!!!!. please can anyone help me?
0
8427
marktang
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...
0
8330
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,...
0
8850
Oralloy
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...
1
8523
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,...
0
8626
tracyyun
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...
1
6178
isladogs
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...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.