Compilation error?

Do you want to discuss about these problems? Go now!
Users are shared (no need to re-register).

Moderator: Board moderators

Post Reply
rte
New poster
Posts: 2
Joined: Tue Mar 22, 2011 2:37 am

Compilation error?

Post by rte » Tue Mar 22, 2011 2:44 am

749570 2011-03-21 23:01:40 Compile Error 0.000 Minimum 27716 C++ 4873 - Penney Game
749569 2011-03-21 23:00:30 Compile Error 0.000 Minimum 27716 C++ 4873 - Penney Game

i don't understand why my code generate compilation error...
can anybody help me?

my code

Code: Select all

#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int BintoInt(string s){
	int k=0;
	for(int i=0; i<3; i++){
		if(s[i]=='H')
			k += (1 << i);
	}
	return k;
}
int main(){
	int n,m;
	scanf("%d", &n);
	for(int nc=0; nc<n ; nc++){
		scanf("%d", &m);
		string cad;
		cin >> cad;
		map < int , int > mapa;
		for(int i=0;i<=37; i++){
			mapa[BintoInt(cad.substr(i,3))]++;
		}
		printf("%d",m);
		for(int i=0; i<=7; i++){
			printf(" %d",mapa[i]);
		}
		printf("\n");
	} 
}


the answer :

The compiler couldn't compile your ANSI C/C++ or FreePascal or
GNU Pascal/Java program.

[Notes: - Select C, C++, JAVA, PASCAL or FREEPASCAL in the @JUDGE_ID field,
to ensure that I'll use the proper compiler. Place a 'program...'
sentence in Pascal or FreePascal.
Note that entry point in Java is a 'main' function in a 'Main' class.
- Do not use more than 1024 characters per line, or 40,000 bytes per
program, if you are submitting your programs by E-Mail.
- Do not use '//' comments except in C++ programs [And Note that this
is not Borland C or Turbo Pascal!].
- Some mail tools reformat your text or the standard mail headers.
I compiled the lines I resent you in the "Program Received" message.
(if your mail system adds extra lines to your letter, please include
a "@end_of_source_code" string after the last source code line).
- Please note that your email should be sent as plain text and the
source code should be IN the body, not as an attachment.

Here are the compiler error messages:

00749569_24.c:7: `string' was not declared in this scope
00749569_24.c:7: parse error before `)'
00749569_24.c: In function `int BintoInt(...)':
00749569_24.c:10: `s' undeclared (first use this function)
00749569_24.c:10: (Each undeclared identifier is reported only once
00749569_24.c:10: for each function it appears in.)
00749569_24.c: In function `int main()':
00749569_24.c:20: `string' undeclared (first use this function)
00749569_24.c:20: parse error before `;'
00749569_24.c:21: `cad' undeclared (first use this function)

thanks...

Marcel Hernandez
New poster
Posts: 7
Joined: Wed Mar 04, 2009 4:00 pm
Location: Barcelona, Spain

Re: Compilation error?

Post by Marcel Hernandez » Sat Mar 26, 2011 3:38 pm

Which compiler are you using? I've copypasted your code in a file and ran g++ code.cpp -lm -lcrypt -O2 -pipe -DONLINE_JUDGE (UVA Judge's compiling options) in a Linux shell using the GNU C++ Compiler v4.4.5, and just got a couple of warnings regarding scanf() :

Code: Select all

code.cpp: In function ‘int main()’:
code.cpp:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
code.cpp:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
But not a single compilation error thus far, you should be fine. Hope this helps.

Post Reply

Return to “ACM ICPC Archive Board”