Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-20-2005, 02:41 PM   #16 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Quote:
Code:
#define FILENAME “C:\\data.dat”
bool Load Array (mt array[] [101])
ifstream input_file;
input file.open (FILENAME)
if ( input_file)
cout << “Cannot Open Input Data File.” << endi;
return false;
for (mt row = 0; row < 101; ++row)
for (mt ccl = 0; ccl < 101; ++col)
input_file >> array[row] [col]
input file.close ()
return true;
What is this gibberish, have you suddently forgotten entirely how to create function, define variables, use a simple main() function ???
Like I said in my previus post, I'm not here to do your homework, it's not me who is trying to learn this stuff.
First of all, make an efford, start a new thread with your current code example and then we can provide you with answers to, how you might proceed in the troubled parts where you're stumped.

Secondly, don't provide the input data, even a dumb chimp can figureout to create 10.000 random numbers, in a forum like this it will only slow loading of the thread alarmingly.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 11-20-2005, 02:47 PM   #17 (permalink)
subodhgupta1
Registered User
 
Join Date: Sep 2005
Posts: 24
subodhgupta1 is on a distinguished road
I'm sorry to do that but I don't know how to start it. If you could help to start that would be great.
Thanks
subodhgupta1 is offline   Reply With Quote
Old 11-20-2005, 03:35 PM   #18 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Here is a few pointers to help you along, first of, in this assingment you need to create a function which will read all your numbers into your list, look at the Sudoku thread for something similar.
Then compare your thoughts to this pseudo-code
Code:
#include <iostream>
#include <fstream>
#define SIZE 101
#define FILENAME "C:\\data.dat"

/* when theres an NxN array you call it a matrix */
int number_matrix[SIZE][SIZE];

bool load_matrix(void)
{
    std::istream in_file(FILENAME);
    if(!in_file || in_file.fail()){
        std::cout << "Error opening file: " << FILENAME << std::endl;
        return false;
    }
    for(int i=0; i < SIZE; ++i)
        for(int j=0; j < SIZE; ++j)
            if(!(in_file >> number_matrix[ i][j])){
                std::cout << "Not enough numbers to fill the matrix" << std::endl;
                in_file.close();
                return false;
            }
    in_file.close();
    return true;
}
Next problem on your aggenda, is to total some predefined row and column in your matrix, considder this pseudo-code
Code:
int total_row(unsigned int row)
{
    int res=0;
    for(int i=0; i < SIZE; ++i)
        res+=number_matrix[row][ i];
    return res;
}

int total_column(unsigned int col)
{
    int res=0;
    for(int i=0; i < SIZE; ++i)
        res+=number_matrix[ i][col];
    return res;
}
Then find some way to combine those functions, so your program will provide you with the needed result, in order to complete this assignment..

Oh. look I practicaly provided you with the answer.. what's next, should I give you the main() function aswell ?
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 11-21-2005, 11:47 AM   #19 (permalink)
subodhgupta1
Registered User
 
Join Date: Sep 2005
Posts: 24
subodhgupta1 is on a distinguished road
I'm really embarrased to say this that my laptop bag got stolen and all my notes were in there on functions I have literally nothing to refer to other than the internet help. So please advise how to call these functions in int main ()
subodhgupta1 is offline   Reply With Quote
Old 11-21-2005, 12:05 PM   #20 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
just call them:
Code:
int main()
{
    int res_row, res_col;
    if( ! load_matrix())
        return -1;
    res_row = total_row(SIZE/2);
    res_col = total_column(SIZE/2);
    std::cout << "Total of row " << SIZE/2 << ": " << res_row << std::endl;
    std::cout << "Total of col " << SIZE/2 << ": " << res_col << std::endl;
    std::cout << "Total of row + col: " << res_row + res_col<< std::endl;
    return (res_row+res_col);
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 11-21-2005, 01:09 PM   #21 (permalink)
subodhgupta1
Registered User
 
Join Date: Sep 2005
Posts: 24
subodhgupta1 is on a distinguished road
Thank you sir thank you very much!!
subodhgupta1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with first php project sarah31 PHP 10 06-14-2004 10:56 PM
SMS provider that offer SMS shipping world-wide for under 0,05 € ??? gicio Lounge 2 05-28-2003 04:46 AM


All times are GMT -8. The time now is 12:27 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting