赞
踩
新生周赛二题解
A:检查有多少不同字符,用一个数组的下标来对应每个26个字符,若其为1则出现过反之
#include<string.h> #include<stdio.h> #include<stdlib.h> char a[10000]; int b[28];//标记不同字符 int main() { scanf("%s", a); for (int i = 0; i < strlen(a); i++) { int c = a[i] - 96; if (b[c] == 0)///如果这个字符没有出现 { b[c]++; } } int count = 0; for (int i = 1; i <= 26; i++) { if (b[i] == 1) { count++; } } if (count
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。