01/10/2018, 17:32
Đếm kí tự chuỗi
Đề bài: Cho xâu S có cả chữ ha và chữ thường. Kiêmr tra xem trong xâu có đúng cả 26 chữ cái không?
Mọi người cho em hỏi là bài code em viết thế này ạ:
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
char alphabet[]="zxcvbnmasdfghjklqwertyuiop";
char string[225];
int count=0;
gets(string);
strlwr(string);
for(int i=0; alphabet[i]!=' '; i++){
if(strchr(string, alphabet[i])) count++;
}
if(count==26) cout<<"YES";
else cout<<"NO";
return 0;
}
Mà em lại bị lỗi thế này là sao ạ??
Compilation Error
/tmp/code.cpp: In function ‘int main()’:
/tmp/code.cpp:9:2: warning: ‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(string);
^
/tmp/code.cpp:9:13: warning: ‘char* gets(char*)’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
gets(string);
^
/tmp/code.cpp:10:15: error: ‘strlwr’ was not declared in this scope
strlwr(string);
^
/tmp/code.cpp:9:14: warning: ignoring return value of ‘char* gets(char*)’, declared with attribute warn_unused_result [-Wunused-result]
gets(string);
```
Bài liên quan
strlwr
ko có trong thư viện<string.h>
C/C++ đều ko có hàm
strlwr
này @_@Vậy ạ, thế mình dùng tolower được không ạ?
ừ, làm cái vòng for rồi gán string[i] = tolower(string[i])
Bài này thì quẩy bảng tần suất cho nhẹ