|
|
back to boardWA 1... What's wrong? #include <stdlib.h> #include <iostream> using namespace std; int main() { int n, cnt = 0; register int j; char shop[1001][31]; char used[5] = "stop"; cin >> n; for(register int i = 0; i < n; i++) cin >> shop[i]; for(register int i = 0; i < n; i++) { if(shop[i] == "stop") break; for(j = i + 1; j <= n; j++) { if(strcmp(shop[j], "stop") != 0) if(strcmp(shop[i], shop[j]) == 0) { cnt++; strcpy(shop[j], "stop"); } } } cout << cnt; } WA 1 The same problem: #include <stdio.h> #include <string.h> void main(void) { char n[1000][31]={'/'}; int i,y,qw,bayan=0; scanf("%d",&qw); for(i=0;i<qw;i++) { scanf("%s",&n[i][0]); for(y=0;y<=i-1;y++) if(strcmp(n[y],n[i])==0) { n[y][0]='/'; bayan++;} } printf("%d",bayan); } Edited by author 20.01.2010 11:12 Edited by author 20.01.2010 11:12 Re: WA 1 "The brands are the strings of Latin letters and blanks"! scanf doesn't read blanks ("aaa bbb" - two words for scanf). Re: WA 1 Posted by DNS 15 May 2010 01:58 I use getline(cin,str); // !!! for(int i=0; i<n;i++){getline(cin,str)... and Accepted. |
|
|