| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Why compile error ?I can not understand why my sources get compile error , I have written 2 for this task :
// 1st one - compile error
#include <iostream>
#include <string>
#include <algorithm>
#define FOR(i,n) for(int i=0;i<n;i++)
using namespace std;
string a,b,tmp,code;
int main() {
cin>>a;
b = a;
while(cin >> tmp) {
code+=tmp;
code+=" ";
}
cout << code;
FOR(i,a.size()) b[i] = toupper(a[i]);
for(int i=0;i<code.size();i++) {
if(code[i] == ' ') cout << " ";
else if(code[i]>='a' && code[i]<='z')cout << a[code[i]-'a'];
else cout << b[code[i]-'A'];
}
cout << endl;
return 0;
}
// 2nd one - compile error
#include <stdio.h>
#include <string.h>
using namespace std;
char a[26],b[26];
char c[81];
int main() {
gets(a);
gets(c);
for(int i=0;i<26;i++) b[i] = a[i] - ('a'-'A');
for(int i=0;i<strlen(c);i++) {
if(c[i] == ' ') printf(" ");
else if(c[i] >= 'a' && c[i] <= 'z') printf("%c",a[c[i]-'a']);
else printf("%c",b[c[i]-'A']);
}
return 0;
}
I compile them as a "C++"
So what is the problem :( Please help
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator