Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-17-2007, 08:00 AM   #1 (permalink)
TAboy24
Recruit
 
Join Date: May 2007
Posts: 2
TAboy24 is on a distinguished road
Thats a taugh problem!!

Hey people!
I need writing descending polynom of the form :
(CX^n)+(CX^n-1)+.....+(CX^1)+(C^0)
every part of the polynom(for example CX^n-1 is one part of many) is represented as:
Typedef struct monom {
int coeficient; //(the "C")
int power; //(the "n")
}Monom;

!*!)write a program getting input 2 polynoms and prints the sum polynom and the multiply polynom of these 2 inputs in diferent lines...

comments: coefficient(C) is never 0 and also the output C isnt!
every polynom of the input is actually a line (unknown length) of pairs(coeficient and power)..for example:
2 4 -5 1 0 6 6 4 -8 0 7 3 represents: 8x^4+7x^3-5x-8 !!


Thats really taughmaybe you suceed better then me
TAboy24 is offline   Reply With Quote
Old 05-17-2007, 10:19 AM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
As replied on many forums to your questions already: What are your attempts so far?
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 05-17-2007, 11:25 AM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
don't you just sort by the power?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 05-18-2007, 10:40 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
It is not really tough once you see what you're really asking for.
Realize that X^k + X^k-1 + X^k-2 | k => 0
is the same as going backwards with k initialized with 0.
That's the first thing.

Second:
The invariant (the property that always remains the same) of
c*X^k == X^m
In normal words: this invariant implies that you only need to create an algorithm that calculates powers - basically!

Good news isn't it?

Let's see if I can create a quick implementation in some pseudo-language.

Code:
k=m; //user input
y=1;
WHILE k != 0 DO
  k=k-1;
  y=y-x;
END WHILE
In the WHILE loop, you add code to multiply with some constant which you have entered on the commandline. That's it!

A faster method for large numbers is available in terms of Horner.
I don't know anything about your mathskills with inequalities and summations. If the skills are there, then I can introduce you to it the formal way with easy to understand pseudo code.

Start playing with the pseudo code I gave you. Translate it into C++. Forget about classes and all the fancy stuff for now. See if you can get anything working.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A small problem in the output the_master Standard C, C++ 1 12-17-2006 09:09 AM
parse error problem in game.. can't seem to find problem solution. slashdot Standard C, C++ 5 08-03-2005 08:15 PM
JSP code problem j.gohel Java 7 04-15-2005 02:07 PM
Problem Assignment (Urgent help req.) Boltress Standard C, C++ 0 01-12-2005 07:59 AM
Help debugging a power problem Belisarius Lounge 0 10-25-2003 04:44 PM


All times are GMT -8. The time now is 04:36 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting