Beantwortet registration in array problem

  • Sonntag, 19. August 2012 23:14
     
     

    i make this code , i have problem , in tab[0][0] i have registration 10 ; how can i avoid this ?

    plik>>liczba;

    printf("[%d]",tab[i][j]);

    for(int i=0;i<2;i++)

    for(int j=0;j<3;j++)

    {

    plik.close();

    if (tab[0][0]=10)// i talk about this  , without this is allright , but i use this condition and i have problem .

    {

    liczba=tab[i][j];

    i=i+1;

    liczba2=tab[i][j];

    tab[i][j]=liczba1;

    i=i-1;

    tab[i][j]=liczba2;

    }

    }

Alle Antworten

  • Sonntag, 19. August 2012 23:21
     
     

    rafal_bator wrote:

    if (tab[0][0]=10)// i talk about this , without this is allright ,  but i use this condition and i have problem .

    if (tab[0][0] == 10)

    = (single equal sign) is assignment; == (two equal signs) is  comparison.


    Igor Tandetnik

  • Sonntag, 19. August 2012 23:23
     
     

    Do you mean to do

    if (tab[0][0] == 10)

    ?

  • Sonntag, 19. August 2012 23:40
     
     

    Thank You

    You must it put it before computing , before loops .

    condition :

    if (tab[0][0]==10)

    {

    (...)

    is correct .



    • Bearbeitet rafal_bator Sonntag, 19. August 2012 23:48 badly test
    • Bearbeitet rafal_bator Sonntag, 19. August 2012 23:49 obviously
    •  
  • Sonntag, 19. August 2012 23:52
     
     Beantwortet

    rafal_bator wrote:

    What is different between assignment and comparision ?

    http://en.wikipedia.org/wiki/Assignment_(computer_programming)
    http://en.wikipedia.org/wiki/Comparison_(computer_programming)


    Igor Tandetnik

    • Als Antwort markiert rafal_bator Montag, 20. August 2012 00:59
    •