I have problem with factions

This is a discussion on I have problem with factions within the C Programming forums, part of the General Programming Boards category; Hi i am knew in the site. I have got problem with a program, and i think is in factions. ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    4

    I have problem with factions

    Hi i am knew in the site.
    I have got problem with a program, and i think is in factions.
    Can sameone help me.
    this is code
    Code:
     #include <stdio.h>
    #include <time.h>
    #include <stdlib.h>
    #define M 4
    #define N 4
    int maximum(int board[][4], int , int );
    int minium(int board[][4],int ,int );
    int main(){
    int board[M][N];
    int max[4],min[4];
    int i,j,min_A={0},max_A={0};
    for (i=0;i<M;i++)
    for (j=0;j<N;j++){
        
    printf("Dwse stoixio[%d][%d]\n",i,j);
    scanf("%d",&board[i][j]);}
    printf("\n");
    for (i=0;i<M;i++){
    for (j=0;j<N;j++)
    printf(" %3d ",board[i][j]);
    printf("\n");
    }
    
    printf("To A_max einai to %d",max_A);
      printf("\nmin ana grami\n");
    for (i=0;i<N;i++)
    printf(" %3d \n",min[i]);
    printf("to A_min einai to %d\n",min_A);
    printf("\nmax ana stili\n");
    for (i=0;i<N;i++)
    printf(" %3d \n",max[i]);
    system("pause");
    } 
    
    int maximum(int board[][4], int m, int n){
        int i,j,min[4],max_A={0};
        for (i=0;i<M;i++){
                min[i]=board[i][0];
            for (j=0;j<N;j++){
                 if (board[i][j]<min[i])
                            min[i]=board[i][j]; }}
                      max_A=min[0];
                      for(i=1;i<N;i++)
     if(max_A<min[i])
      max_A=min[i];
    return max_A;}
    
    int minium(int board[][4],int m,int n){
        int i,j,max[4],min_A={0};
        for (i=0;i<N;i++){
    max[i]=board[0][i];
    for (j=0;j<M;j++){
    if (board[j][i]>max[i])
    max[i]=board[j][i];}}
    min_A=max[0];
    for(i=1;i<N;i++)
     if(min_A>max[i])
      min_A=max[i];
      return min_A;}
    Sorry for my bad english.
    Last edited by VagosM; 12-14-2010 at 07:44 AM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    FYI - You are never calling the max_A() or min_A() functions.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    You can't have a function's name the same as a variable's... max_A=min[0];

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    4
    i cant make it..
    Code:
     #include <stdio.h>
    #include <time.h>
    #include <stdlib.h>
    #define M 4
    #define N 4
    int maximum(int board[][4], int , int );
    int minium(int board[][4],int ,int );
    int main(){
    int board[M][N];
    int max[4],min[4];
    int i,j,min_A={0},max_A={0};
    for (i=0;i<M;i++)
    for (j=0;j<N;j++){
        
    printf("Dwse stoixio[%d][%d]\n",i,j);
    scanf("%d",&board[i][j]);}
    printf("\n");
    for (i=0;i<M;i++){
    for (j=0;j<N;j++)
    printf(" %3d ",board[i][j]);
    printf("\n");
    }
    
    printf("To A_max einai to %d",minium(board[][4],m,n));
      printf("\nmin ana grami\n");
    for (i=0;i<N;i++)
    printf(" %3d \n",min[i]);
    printf("to A_min einai to %d\n",maximum(board[][4],m,n));
    printf("\nmax ana stili\n");
    for (i=0;i<N;i++)
    printf(" %3d \n",max[i]);
    system("pause");
    } 
    
    int maximum(int board[][4], int m, int n){
        int i,j,min[4],max_A={0};
        for (i=0;i<M;i++){
                min[i]=board[i][0];
            for (j=0;j<N;j++){
                 if (board[i][j]<min[i])
                            min[i]=board[i][j]; }}
                      max_A=min[0];
                      for(i=1;i<N;i++)
     if(max_A<min[i])
      max_A=min[i];
    return max_A;}
    
    int minium(int board[][4],int m,int n){
        int i,j,max[4],min_A={0};
        for (i=0;i<N;i++){
    max[i]=board[0][i];
    for (j=0;j<M;j++){
    if (board[j][i]>max[i])
    max[i]=board[j][i];}}
    min_A=max[0];
    for(i=1;i<N;i++)
     if(min_A>max[i])
      min_A=max[i];
      return min_A;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

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