Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************************************************\
- | _ ____ _ _ ____ |
- / \ | \ | / \ | \ | | \ | / \ |
- / \ | \ | / \ | \ | | \ | / \ |
- /-----\ | \ | | | | \ | | \ | | | |
- / \ | \ | \ / | \ | | \ | \ / |
- / \ | \_| \____/ | \_| | \_| \____/ |
- |
- |
- codeforces: safayet007 || codechef: saf1ano2_1234 |
- BUET EEE '17 |
- |
- **********************************************************************/
- #include <stdio.h>
- int strrlen(char *str)
- {
- int length = 0, i;
- for(i = 0; *(str + i); i++)
- {
- length++;
- }
- return length;
- }
- int strcmp(char *text, char *pattern)
- {
- int x = strlen(text), y = strlen(pattern), n = (x < y? x: y), i;
- for(i = 0; i < n; i++)
- {
- if(*(text + i) < *(pattern + i)) {
- return -1;
- }
- else if(*(text + i) > *(pattern + i)) {
- return 1;
- }
- }
- if(x == y) {
- return 0;
- }
- else if(x < y) {
- return -1;
- }
- else {
- return 1;
- }
- }
- int main()
- {
- char a[256];
- char b[256];
- gets(a); gets(b);
- printf("%d\n", strcmp(a, b));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement