比較兩個字符串的大小,不使用strcmp函數。程序輸出1、0或-1,分別代表字符串1大於字符串2、兩個字符串相等、字符串1小於字符串2。

#include<stdio.h> #include<math.h> #define M 20 #define N 20 main() { char a[M],b[N]; int i,t=0,p,q; printf(「請輸入第一個字符串:」); gets(a); printf(「請輸入第二個字符串:」); gets(b); p=strlen(a); q=strlen(b); for(i=0;a[i
相關文章
相關標籤/搜索