i don't succeed into making an array of 20 lines and 20 columns filled with zeros

This is a discussion on i don't succeed into making an array of 20 lines and 20 columns filled with zeros within the C++ Programming forums, part of the General Programming Boards category; Hi, i'm trying to make an array of 20 lines and 20 columns filled with zeros, but for now it ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    54

    i don't succeed into making an array of 20 lines and 20 columns filled with zeros

    Hi, i'm trying to make an array of 20 lines and 20 columns filled with zeros, but for now it is not working. Basically, it's an array initialized (filled with zeros), that is then displayed. Here's my code :

    Code:
    #include <iostream>       // lectures et �critures (I/O)
    #include <iomanip>        // manipulation des I/O, pas besoin pour le moment
    #include <cstdlib>        // Bibliothèques C
    
    
    using namespace std;
    
    
    /****** Declarations globales ******/
    // ========= constantes ========== //
    
    
    // ============ types ============ //
    
    
    
    
    // ========== variables ========== //
    
    
    // ========== fonctions ========== //
    
    
    
    
    float initialisation_grille()
    {
       float grille[20][20];
       int ligne ; int colonne ;
       for ( ligne = 0 ; ligne <= 20 ; ligne ++ )
            {  for ( colonne  = 0 ; colonne < 20 ; colonne ++ )
                        {  grille [ ligne ] [ colonne ] = '0' ;
                            }
    
    
                    }
    return grille[20][20];
    }
    
    
    
    
    void affichage_grille ( float grille[20][20] ) { //grille est en entree car le SP doit connaitre
    float toto[20][20];                                                                   // ses valeurs pour les afficher
    
    
     int ligne ;
     int colonne ;
     for ( ligne = 20; ligne >=0 ; ligne --){
                                                for ( colonne = 0 ; colonne <20; colonne ++ ){
                                                cout<< toto [ ligne ] [ colonne]<<'\t' ;
                                                        }
          cout << endl ;
        }
    }
    
    
    
    
    /*float donner_coefficients_table_de_routh__et_remplir_deux_premieres_lignes (  int x, int degre_denominateur ){
    float y;
    float t_tableaudecoefficients [25];
    int c=0;
    int l=0;
    for (x=degre_denominateur ; x>=0 ; x--){
                                    cout<<"quel est le coefficient associe au degre"<<x<<"?"<<endl;
                                    cin>> y;
                                    y = t_tableaudecoefficients[x];
                                    if ( (l==2) ){ l=0 ; c++; }
                                            t_table2[l][c] = y;
                                            l++;
                                  }
    return y;
    }
    
    
    /*void effectuer_calcul_table_de_routh( float t_table2toto){
    int ligne;
    int i;
    float t_table2[20][20];
        for (ligne=0 ; ligne<=20 ; ligne++){
    
    
                    for (i=2 ; i<=20 ;i++ )  {
                                                int r;
                                                r=ligne-2;
                                                int s;
                                                s=ligne-1;
                                                int f;
                                                f=i+1;
    
    
                                                t_table2[ligne][i] = ( t_table2[r][f] - ( (t_table2[s][f]) * ( (t_table2[r][ligne])/(t_table2[s][ligne]) ) )  ) ;
                                               ;
                                }
    
    
        }
    
    
    }
    
    
    /*
    
    
    
    
    
    
    
    
    /******* Programme principal *******/
    
    
    int main(){
    float tata[20][20];
    initialisation_grille();
    affichage_grille (tata);
    cout<<"quel est le degre du denominateur ?"<<endl;
    cout<<"toto"<<endl;
    system("PAUSE");
    //cout<<"quel est le degre du denominateur?"<<endl;
    //cin>> degre_denominateur ;
    //donner_coefficients_table_de_routh__et_remplir_deux_premieres_lignes ( x, degre_denominateur );
    //effectuer_calcul_table_de_routh(t_table2 [20][20]);
    //affichage_grille (t_table2 [20][20]);
    //system("PAUSE");
    }
    Any help would be appreciated

  2. #2
    ysg
    ysg is offline
    Registered User
    Join Date
    Feb 2013
    Posts
    27
    I take it that when you run your program, nothing is printed out, yes?

    [edit]

    Is this a homework assignment?

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Not a lot of progress in two days.
    http://cboard.cprogramming.com/cplus...ore-float.html

    Except the code looks worse than ever.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    ysg
    ysg is offline
    Registered User
    Join Date
    Feb 2013
    Posts
    27
    Quote Originally Posted by Salem View Post
    Not a lot of progress in two days.
    http://cboard.cprogramming.com/cplus...ore-float.html

    Except the code looks worse than ever.
    Kinda hard to blame him, the language barrier (or lack of adequate instructional material in his native language) makes learning C++ that much more difficult.

    I'll have to look at this at home.

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    Yes, I admit it's a shame. But i'm only looking for some improvement in c#, and i'm just beginning. To answer to ysg, when i run the program something is printed out, but it's not what i want :
    what is displayed is an array filled mainly with 48 and for another part it's filled with some calculations.

    i just do it as a training exercise, nothing for school, because as Salem said in other words, i need to improve in c#.
    Thank you in advance for your help and your answers

  6. #6
    ysg
    ysg is offline
    Registered User
    Join Date
    Feb 2013
    Posts
    27
    Quote Originally Posted by funnydarkvador View Post
    Yes, I admit it's a shame. But i'm only looking for some improvement in c#, and i'm just beginning. To answer to ysg, when i run the program something is printed out, but it's not what i want :
    what is displayed is an array filled mainly with 48 and for another part it's filled with some calculations.

    i just do it as a training exercise, nothing for school, because as Salem said in other words, i need to improve in c#.
    Thank you in advance for your help and your answers
    If you want to improve in C#, why are you writing C++ code?

  7. #7
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    Sorry, in C++ i meant

  8. #8
    ysg
    ysg is offline
    Registered User
    Join Date
    Feb 2013
    Posts
    27
    funnydarkvador, here is a free/open source IDE that you can use for C# development (very easy to setup, has an install wizard):
    SharpDevelop @ic#code

    Here are two tutorials to get you started:
    - Tutorial Contents
    - C# Tutorials (C#)

    Good luck .

  9. #9
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    My aim is just to create two functionsin my program :


    -the first that we could call« initialization » that fills an array of 20 lines and 20columns with zeros
    -the second that we could call« display » that just displays the array initialized


    i want my function display to be thenused in my program for any other array that i want to be displayed inmy program (by passing it as a parameter).

  10. #10
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    i meant C++, but thank you nevertheless ysg, i'm also interested in C#

  11. #11
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    You can give me an example in english of what i want to do ( the two functions which i was telling you about in this thread), i perfectly understand english

  12. #12
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    Please i need help !! It must be easy when you are an informed programmer, but to create these two functions, i've been trying plenty of things that didnt' work

  13. #13
    ysg
    ysg is offline
    Registered User
    Join Date
    Feb 2013
    Posts
    27
    Quote Originally Posted by funnydarkvador View Post
    Please i need help !! It must be easy when you are an informed programmer, but to create these two functions, i've been trying plenty of things that didnt' work
    Calm down. I did 50% of it for you.
    Code:
    /**
     * four-hundred-zeroes.cpp:
     */
    #include <iostream>
    
    void initArray(int largeArray[20][20])
    {
        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 20; y++)
            {
                largeArray[x][y] = 0;
            }
        }
    }
    
    void printOutArray(int largeArray[20][20])
    {
    }
    
    int main(int argc, char * argv[])
    {
        int largeArray[20][20];
        initArray(largeArray);
        printOutArray(largeArray);
    
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        std::cin.get();
    
        return 0;
    }
    You'll have to develop the print method. It's easy and you should be done with it relatively quickly.

  14. #14
    Registered User
    Join Date
    Feb 2013
    Posts
    54
    Thank you very much !! I'm trying right now to finish it

  15. #15
    ysg
    ysg is offline
    Registered User
    Join Date
    Feb 2013
    Posts
    27
    If you're having trouble with something like that, I propose you run through a tutorial or a good C++ book.

    You'll need a better grasp of the language and how the underlying info flows in order to continue to
    advance.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking to see if an array is filled
    By ljgerr93 in forum C Programming
    Replies: 5
    Last Post: 10-17-2011, 12:48 PM
  2. making rows in terms of columns?
    By x2x3i5x in forum C Programming
    Replies: 2
    Last Post: 11-30-2009, 10:53 PM
  3. File handling with Array filled with a class
    By MarlonDean in forum C++ Programming
    Replies: 18
    Last Post: 06-27-2008, 10:53 AM
  4. Replies: 3
    Last Post: 11-16-2007, 02:10 PM
  5. Filled array
    By GaPe in forum C Programming
    Replies: 2
    Last Post: 12-11-2001, 04:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21