Kirjautuminen

Haku

Tehtävät

Keskustelu: Yleinen keskustelu: mikä ohjelmointikieli

Sivun loppuun

aWW [13.02.2005 18:21:09]

#

En ole varma nillä ohjelmointikielellä tuo ohjelma on kirjoitettu, veikkaisin c:tä, mutta &ltiostream.h> ja
� häiritsevät

/*********************************************
* Program : Horner's formula for converting
* to decimal numeric system.
*
* Date : 25 September 2001
* Author : Ilia Yordanov, Loobian
*********************************************/
//Including the libraries #1
#include &ltiostream.h>
#include &ltstring.h>
//End of #1

//This is the function that makes the convertion
//It takes 3 parameters- char *array, unsigned short int system
//and int size.
//char *array is the array where is stored the number to be
//converted. Every digit of it must be in one cell
//unsigned short int system, stores which numeric system is
//the number in, and int size stores the size of the array
void horner(char *array,unsigned short int system,int size)
{

�int *result;

�result=new int[size];
�result[0]=array[0]-48;

�//Main loop that makes the convertion itself
�for(int g=0;g&ltsize;g++)
��result[g+1]=result[g]*system + (array[g+1]-48);

&#65533;cout << "Result in decimal: "<&ltresult[size-1]<&ltendl;

}


//Main function
void main()
{
&#65533;char a[100];
&#65533;unsigned short int sys;

&#65533;cout << "Enter number: ";
&#65533;cin >> a;
&#65533;int size=strlen(a); //Get the size of the array
&#65533;cout << "What numeric system is your number in? : ";
&#65533;cin >> sys;

&#65533;horner(a,sys,size);


}

p-p [13.02.2005 18:24:49]

#

&#65533; on rikkinäinen merkki ja &lt on < merkki. Iostreamhan on c++ kirjasto. Ja siellähän on kaikki coutit sun muut...

aWW [13.02.2005 18:29:17]

#

olisi pitänyt arvata >(

Blaze [13.02.2005 18:29:55]

#

No C++:aahan tuo on ihan selkeästi.

aWW [13.02.2005 18:37:29]

#

tiedän (cin,cout), oudot merkit häiritsivät liikaa, enkä lukenut koodia

Blaze [13.02.2005 18:58:36]

#

Et ees vaivautunu lukemaan, mutta tulit kyllä tänne kysymään? o_O
Ei näin.

aWW [13.02.2005 19:10:32]

#

yritin kyllä kääntaä sitä, mutta mikään tulkki ei tunnistanut sitä

Metabolix [13.02.2005 19:19:19]

#

No ei varmaan, kun on tuollaisia outoja merkkejä ja tuo &lt. Olisit lukenut vain. Se on varmasti nopeampaakin kuin yrittää kääntää sitä. Ja C:tähän ei syötetä millekään tulkille vaan kääntäjälle, eli tulkki tuskin C++:aa tulkkaisi.

Meitsi [13.02.2005 19:20:05]

#

No ei varmaan käännä kun nuo merkit ovat sekaisin.

Ilmuri [14.02.2005 01:01:54]

#

The dreaded websafe code of oblivion. :I


Sivun alkuun

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta