输入一串字符,统计其中相邻字符对出现的次数。例如,ab、ef都是相邻字符对
可以参考
#include <stdio.h>
#include <string.h>
int main() {
char str1[50];
gets(str1);
int count = 0;
int lenth = strlen(str1);
for (int i = 0; i < lenth-2; i++) {
int temp = str1[i] - str1[i + 1];
if(temp == 1 || temp == -1) count++;
}
printf(count);
return 0;
}