Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 02:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Hilfe in Info mit Arrays via Java

Discussion on Hilfe in Info mit Arrays via Java within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2007
Posts: 248
Received Thanks: 15
Hilfe in Info mit Arrays via Java

Heho,ich sitz grad hilflos in Info.
Kann mir wer mit dieser Aufgabenstellung helfen?

Berechnen Sie die Fakultät bis 10! und speichern Sie sie in einem Array. (Unter 5! gesprochen "Fünf Fakultät", versteht man als 1*2*3*4*5=120.
Es wird definiert: 0! = 1)

wär nett,

lg

blacky
b!4ck-d34th is offline  
Old 11/17/2009, 12:55   #2

 
x]vIrus[x's Avatar
 
elite*gold: 37
Join Date: Apr 2004
Posts: 2,154
Received Thanks: 250
Code:
int fack (int f)
{
 int r=1;
 for (int i = 2 ; i < f; i++)
 {
  r*=i;
 }
 return r;
}
was auch immer dein lehrer will :s
x]vIrus[x is offline  
Thanks
1 User
Old 11/17/2009, 20:21   #3

 
Adroxxx's Avatar
 
elite*gold: 15
Join Date: Nov 2005
Posts: 13,021
Received Thanks: 5,323
PHP Code:
  public static int fakultaet(int n) {
             return (
== 0) ? fakultaet(1);

schade, gerad erst richtig gelesen, dass es im array abgespeichert werden soll.. naja waye ;D
vll kannst du es ja trotzdem gebrauchen.
Adroxxx is offline  
Thanks
1 User
Old 11/17/2009, 21:45   #4
 
elite*gold: 0
Join Date: Oct 2007
Posts: 248
Received Thanks: 15
kay kay ich werds mal antesten ich bedanke mich,
lg
blacky
b!4ck-d34th is offline  
Old 11/18/2009, 13:03   #5

 
x]vIrus[x's Avatar
 
elite*gold: 37
Join Date: Apr 2004
Posts: 2,154
Received Thanks: 250
meins is schneller, braucht weniger ram und kann kein stack overflow verursachen :x
x]vIrus[x is offline  
Old 11/18/2009, 15:11   #6

 
Adroxxx's Avatar
 
elite*gold: 15
Join Date: Nov 2005
Posts: 13,021
Received Thanks: 5,323
Dafür ist meins kompakter und übersichtlicher :P
Adroxxx is offline  
Old 11/20/2009, 12:37   #7
 
elite*gold: 0
Join Date: Oct 2007
Posts: 248
Received Thanks: 15
ich hab mich jetzt nochmal drangesetzt, es müsste irgendwie so innerhalb
eines arrays funktionieren. jedoch klappt es noch nicht wirklich.
irgendwelche tipps?

Code:
import java.applet.*; import java.awt.*;

public class fack extends Applet {
  public fack () {
    int a [] = new int [11];

    for (int n=0; n<=10; n++ ) {

      a[0]= n*(n-1);
      a[1]= n*(n-1);
      a[2]= n*(n-1);
      a[3]= n*(n-1);
      a[4]= n*(n-1);
      a[5]= n*(n-1);
      a[6]= n*(n-1);
      a[7]= n*(n-1);
      a[8]= n*(n-1);
      a[9]= n*(n-1);
      a[10]= n*(n-1);

      
      
      Label l = new Label ( "Fack! " + n*(n+1) );
      add(l);
    }
  }
}
b!4ck-d34th is offline  
Old 11/20/2009, 13:59   #8
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,426
Received Thanks: 1,888
wenn schon, dann a[n]
MoepMeep is offline  
Old 11/20/2009, 21:36   #9

 
x]vIrus[x's Avatar
 
elite*gold: 37
Join Date: Apr 2004
Posts: 2,154
Received Thanks: 250
asoooo
etz weiß ich "vielleicht" was dein lehrer will:

Code:
string fuckString(int[] bla)
{
  string s ="****: ";
  for ( int i = 0 ; i < bla.size();i++)
  {
    s+=i.toString()+"! = "+bla[i].toString()+"\n";
  }
}

int[] ****(int k)
{
  ArrayList<int> l = new ArrayList<int>();
  int r=1;

  if ( k >= 0 ) l.add(1);
  for ( int i=1;i<k;i++)
  {
    r*=i;
    l.add(r);
  }
  return l.toArray();
}
x]vIrus[x is offline  
Old 12/03/2009, 11:01   #10
 
elite*gold: 0
Join Date: Oct 2007
Posts: 248
Received Thanks: 15
für die leute die's interessiert, hier das Ergebnis^^

Code:
import java.applet.*; import java.awt.*;

public class fack fertig extends Applet {

  // Anfang Attribute
  // Ende Attribute

  public fack fertig () {
    int a [] = new int [11];

    for (int n=1; n<=10; n++ ) {

      a[0]= 1;


      
      a[n]= a[n-1]*(n);
      
      Label l = new Label ( n+"Fack = " +a[n] );
      add(l);
    }

    // Anfang Komponenten
    // Ende Komponenten
  }

  // Anfang Methoden
  // Ende Methoden
}

danke an alle^^
b!4ck-d34th is offline  
Reply


Similar Threads Similar Threads
Arrays! Hilfe!
06/29/2010 - AutoIt - 13 Replies
Hallo e*pvp, Es ist mir jetzt peinlich aber irgendwann musste ich es fragen! Also Ich habe ein Problem undzwar versteh ich nicht was Arrays sind. Ich versteh den Sinn nicht und nicht wie man sie Anwenden kann! Die ganzen Texte aus Wikipedia und Arrays Tutorials helfen mit nicht! Bitte hilft mir was genau Arrays sind und wie man sie sinnvoll anwenden kann! Ich hoffe einer kann mir helfen :( !
[Java] Code-Beispiele für String, Arrays und und...
06/02/2010 - Coding Tutorials - 9 Replies
Joa, da ich Heute meine Informatik Prüfung in der Uni hatte ( und es sollte wohl min. eine 2 raus gekommen sein ) hatte ich Gestern so in ner Stunde einige Code Beispiele für verschiedene Dinge geschrieben. Eins war wie man Strings verarbeiten kann, was man mit Arrays anstellen kann und noch so paar Allgemeine Sachen zur Vererbung und Klassen. Man sollte das hier nicht unbedingt als Tutorial sehen da ich euch eigentlich hier einfach nur Code reinhau den ihr direkt Ausführen könnt wenn ihr...
[Java Release with Source] Account Info Saver
11/09/2008 - CO2 Programming - 6 Replies
Hey everyone, I made a little quick program in java (It's my first one besides hello world) Anyways, basically what this does is save an account in your Conquer(Only if it's C:\Program Files\Conquer 2.0\) folder in a file called whatever you made your LoginID. Edit: Figured it out. Updated Attatchments I've included the source code just as a little reference for people that are learning Java like myself. sharing is caring.
Account info saver [Java]
09/27/2008 - CO2 Exploits, Hacks & Tools - 31 Replies
Ok, I made this tonight pretty quickly. I'm learning Java currently and I think this is useful, and I know there are others, but eh, here it is anyways. I'm open to suggestions to be added into this. (i.e. Pick your own save location, Upload file to FTP server, etc.) #Updated (9-15-08) Now can Save and Read info in one file. Use the readme for more info. The source for this version is in the Programming section, you can find it there



All times are GMT +2. The time now is 02:08.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.