473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to eliminate this warning?

hello ,all

i got this warning:

under emacs using GCC 4.0.1 gpp(DJGPP) compiler:

gpp -Wall -g lizards.cpp
Invalid keyboard code specified
lizards.cpp: In function 'int maxflow(int (*)[1000], int, int, int)':
lizards.cpp:56: warning: suggest parentheses around assignment used as
truth value

part of my code:
typedef int Graph[MAXN][MAXN];
Graph g;
.....
int augment(Graph g, int n, int s, int t);
....
int maxflow(Graph g, int n, int s, int t)
complete listing:

#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
#define REP(i,n) for(int _n=(n),i=0;i<_n;i++)
#define FOR(i,a,b) for(int _b=(b),i=(a);i<=_b;i++)
/////////
const int INF = 1000000000;
const int MAXN = 1000;
typedef int Graph[MAXN][MAXN];
Graph g;
int cap[MAXN],vis[MAXN],src[MAXN];
int n,m,disLeap,nlizards,nvec,source,sink;
char map[30][30], lid[30][30];

int augment(Graph g, int n, int s, int t)
{
int i, j;
int max, mloc;

memset(vis,0,sizeof(vis));
memset(cap,0,sizeof(cap));
cap[s] = INF;
while (1) {
mloc = -1;
max = 0;
for (i=0; i<n; i++)
if (!vis[i] && cap[i]>max) {
mloc = i;
max = cap[i];
}
if (mloc == -1) return 0;
if (mloc == t) break;

vis[mloc] = 1;
for (i=0; i<n; i++)
if (g[mloc][i]>cap[i] && max>cap[i]) {
cap[i] = g[mloc][i];
if (cap[i]>max) cap[i] = max;
src[i] = mloc;
}
}
max = cap[t];
for (i=t; i!=s; i=src[i]) {
j = src[i];
g[j][i] -= max;
g[i][j] += max;
}
//cerr << max << endl;
return max;
}

int maxflow(Graph g, int n, int s, int t)
{
int c=0,p;
while (p=augment(g, n, s, t)) c+=p;
return c;
}

inline int dist2(int x1,int y1,int x2,int y2) {
return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
inline int inNode(int r, int c) {
return (r*m+c)*2+2;
}
inline int outNode(int r, int c) {
return (r*m+c)*2+3;
}

void read_graph()
{
memset(g,0,sizeof(g));
nlizards = 0;
source = 0; sink = 1;

scanf("%d%d\n", &n,&disLeap);
REP(i,n) gets(map[i]);
REP(i,n) gets(lid[i]);
m = strlen(map[0]);
nvec = n*m*2+2;

int leap2 = disLeap*disLeap;
REP(row,n) REP(col,m) {
int in = inNode(row,col);
int out = outNode(row,col);
g[in][out] = map[row][col]-'0';
if (lid[row][col]=='L') {
g[source][in] = 1;
++nlizards;
}

if ((row<disLeap || row>n-1-disLeap ||
col<disLeap || col>m-1-disLeap))
g[out][sink] = INF;

REP(i,n) REP(j,m)
if (((row!=i || col!=j)
&& dist2(row,col,i,j)<=leap2))
g[out][inNode(i,j)] = INF;
}
}

int main()
{
int nkase;
freopen("lizards.in","r",stdin);
scanf("%d",&nkase);
FOR(kase,1,nkase) {
read_graph();
//cout << nvec << " " << source << " " << sink << endl;
int res = nlizards - maxflow(g, nvec, source, sink);
printf("Case #%d: ", kase);
if (res==0) printf("no lizard was left behind.\n");
else if (res==1) printf("1 lizard was left behind.\n");
else printf("%d lizards were left behind.\n", res);
}
return 0;
}

Feb 24 '06 #1
2 1765
* blackswift:
hello ,all

i got this warning:

under emacs using GCC 4.0.1 gpp(DJGPP) compiler:

gpp -Wall -g lizards.cpp
Invalid keyboard code specified
lizards.cpp: In function 'int maxflow(int (*)[1000], int, int, int)':
lizards.cpp:56: warning: suggest parentheses around assignment used as
truth value


As the warning says, int function 'maxflow' (which is just a few lines)
you have used an assignment as a truth value. The warning also says how
to eliminate the warning if that is really what you mean. Have you at
all _read_ the warning?

[extranous code listing snipped]
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 24 '06 #2
thanks. i got it.

i thought this warning is caused by the arugments tansforming.
but it is caused by the assignment.

Feb 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Gianni Mariani | last post by:
I have a couple of template methods that take any integer type however, the first "if" statement becomes a constant expression when T is an unsigned type. #include <limits> template...
3
by: Tony Young | last post by:
Hi, I have a multimap container. I want to eliminate all "duplicate" elements. By duplicate I mean something like (3, 4), (4, 3) and (4, 3), in which I want to eliminate any two of these...
3
by: Bill Burris | last post by:
How do I find what is causing this warning from the Linker? If I use /NODEFAULTLIB I get hundreds of undefined symbols. LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other...
8
by: tron.thomas | last post by:
I'm using Microsoft Development Environment 2002 Version 7.0.9466 on Windows XP Professional Service Pack 2. If I compile the following code at maximum warning level: #include <functional> ...
11
by: Michael Mayo | last post by:
I have a simple html page that contains an image in a single table cell, surrounded by a border: <http://www.softrains.com/lc/test.html>. I would like to eliminate the space between the table...
1
by: spanov | last post by:
i've got problem installing python-2.3.5 from sources on FreeBSD 5.3 root@server# ./configure > conf_log configure: WARNING: curses.h: present but cannot be compiled configure: WARNING:...
56
by: Ed Jay | last post by:
I note in an Eric Meyers book that he expresses one goal of using CSS is to eliminate all <brtags. Why? -- Ed Jay (remove 'M' to respond by email)
4
by: cody | last post by:
It is possible to declare and use/instantiate a class with a uninitialized readonly field without even a compiler warning. Why don't I get warnings? public class Stuff { public readonly int a;...
18
by: chilipepas | last post by:
Hello. I receive from a database a variable number of results. In my page, I can show a maximum of 36 results. I want to "neatly" eliminate the exceeding results. For example: say, we...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.