Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 03-29-07   #1 (permalink)
New to Overclock.net
 
Join Date: Mar 2007
Posts: 1

Rep: 0 chakena02 Unknown
Unique Rep: 0
Trader Rating: 0
Default A C++ question!

I am not really a programmer.I don't even know if this code will work. We are suppose to be writing a program to generate bingo. Using a two-dimensional array. The call input is an array of 80 elements. We are reading the bingo cards and bingo calls from an input file. I keep the 2 errors a function-definition is not allowed here before '{' token on line 71 and 88 in the function search and the function check. Here is my code.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

void card(int card1[5][5], int call[80],int row, int col);
void search(int card1[5][5], int searchkey, int &row, int &col);
void check(int card1[5][5], int row, int col);

using namespace std;


//Declare the input file and the output file
ifstream infile1;
ifstream indata;
ofstream outfile;

int main()
{
//Declaring variables
int card1[5][5];
int call[80];
int row, col;
int searchkey;
card(card1,call,row,col);
infile1.close();
indata.close();
outfile.close();
system("pause");
return 0;
}

void card(int card1[5][5], int call[80],int row, int col)
{
int i = 0;
int searchkey;
int count = 0; //count for card number
int count1 = 0; //count for total calls read
int count2 = 0; //count for covered numbers
infile1.open("bingo.dat");
//Reading the numbers into the array
infile1 >> card1[row][col];
while(!infile1.eof())
{
//Placing the numbers into the columns
{for(row = 0; row < 5; row++)
//Placing the numbers into the rows
for(col =0; col < 5; col++)
infile1 >> card1[row][col];
count++; //count for card number
}
indata.open("calls.dat");
outfile.open("game.txt");
indata >> call[count1];
while(!indata.eof())
{
count1++;
search(card1,searchkey,row,col);
check(card1,row,col);
infile1 >> card1[row][col];
}
}
//searches each column on card for number called
void search(int card1[5][5], int searchkey, int &row, int &col)
{

for(int row = 0; row < 5; row++)
{
for(int col = 0; col < 5; col++)
{searchkey = call[count1];
if(searchkey == card1[row][col])
{row = -2;
col = -2;
count2++;
return;
}
}
}

}
void check(int card1[5][5], int row, int col)
{
//check diagonals
card1[3][3] = -2;
int numsdiag1 = 0;
int numsdiag2 = 0;
int numscol = 0;
int numsrow = 0;
{if(card1[row][col] < 0)
numsdiag1++;
else if(card1[row][4-col] < 0)
numsdiag2++;
else if(card1[0][col] < 0)
numscol++;
else if(card1[row][0] < 0)
numsrow++;
}
outfile << "card #" << count << ":" << endl;
{if(numsdiag1 == 5)
outfile << setw(3) << "BINGO occurs on diagonal 1" << endl;
else if(numsdiag2 == 5)
outfile << setw(3) << "BINGO occurs on diagonal 2" << endl;
else if(numscol == 5)
outfile << setw(3) << "BINGO occurs on column"[i] << endl;
else if(numsrow == 5)
outfile << setw(3) << "BINGO occurs on row"[i] << endl;
}
outfile << setw(3) << count2 << "items were covered on this card" << endl;
outfile << endl;
outfile << endl;
}
}
chakena02 is offline   Reply With Quote
Old 03-29-07   #2 (permalink)
.
 
Chipp's Avatar
 
intel ati

Join Date: Dec 2004
Location: At Rehersal
Posts: 13,899
Blog Entries: 28

FAQs Submitted: 18
Hardware Reviews: 3
Trader Rating: 9
Default

I've moved your thread to the coding and programming forum where it will be better suited.

System: The Production Box
CPU
Intel E2160 @ 3.1ghz (Summer OC)
Motherboard
Abit IP35-E
Memory
2x1gb OCZ Plat Rev. 2 DDR2
Graphics Card
ATI X1900XT
Hard Drive
120gb Hitatchi Deskstar IDE
Sound Card
E-Mu 0404 USB
Power Supply
CoolerMaster RM-500
Case
CoolerMaster Centruion 5
CPU cooling
Ultra90 (lapped) and Sanyo Denki 92mm
GPU cooling
Zalman VF900
OS
Windows XP
Monitor
Viewsonic VE175b
Chipp is offline Overclocked Account Chipp's Gallery   Reply With Quote
Old 03-29-07   #3 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,336

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 346
Hardware Reviews: 8
Trader Rating: 8
Default

I dont have time to really look at it right now but when I compiled it i got 7 errors . . .most being unreferenced local variables. . . Ill try to look at it later after class/practice
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Old 03-29-07   #4 (permalink)
Apple Doesn't Love You
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 4,975
Blog Entries: 1

Rep: 564 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

There definitely should not be a bracket before the first 'if' of the check function
__________________
BIG BROTHER
I put on my robe and wizard hat...

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 03-29-07   #5 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,336

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 346
Hardware Reviews: 8
Trader Rating: 8
Default

Quote:
Originally Posted by rabidgnome229 View Post
There definitely should not be a bracket before the first 'if' of the check function
agreed. . . .it should be on the line after it. . .
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 01:32 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.23802 seconds with 8 queries