函数调用遇到的问题
程序代码:
#include<stdio.h> #include<ctype.h> #include<stdbool.h> #define N 26 void read_word(int counts[N]); bool equal_array(int counts1[N], int counts2[N]); int main() { int counts[N], counts1[N], counts2[N], j; char ch, a[N]; printf("Enter first word:"); read_word(counts1); printf("Enter second word:"); read_word(counts2); bool equal_array(counts1, counts2); if (j = true) //@ printf("\nThe waords are anagrams.\n"); else printf("The waords are not anagrams.\n"); return 0; } void read_word(int counts[N]) { int i; char a[N]; for(i = 0; i < N; i++) scanf("%d", &a[i]); tolower(a[i]); isalpha(a[i]); } bool equal_array(int counts1[N], int counts2[N]) { int i,j; for(i = 0; i < N; i++){ if(counts1[i] == counts2[i]) return j = true; else return j = false; } }
编程测试2个单词是否为变位词(相同字母的重新排列 比如smartest mattress)..问题有2。1.为什么第二次调用read_word函数的时候不会出来那个输入第二个单词的呢? 2.如果最后return true或者false那么注释@的那个地方该如何改动呢?直接if (true)???虚心求教