#include <stdio.h>
#include <ctype.h>
#pragma mark counts the number of characters in each letter entered from the terminal. Use the # sign as the input end flag
int main ()
{
int num[26] = {0}, I; char c;
while ((c = GetChar ()) = = ' # ') {
if (Isupper (c)) {
num[c-65]++;
}
}
for (int i = 0; i<26; i++) {
if (Num[i]) {
printf ("%c:%d\n", i+65, Num[i]);
}
}
return 0;
}
#pragma mark counts the number of words in a line of characters
int main ()
{
Char s[81];
int I, c, num=0,word=0;
Gets (s);
for (i=0; (c=s[i])! = ' + '; i++) {
/* One: judging */
if (c = = 32) {
word++;
}else continue;
}
/* Two: judging */
if (c== ') word = 0;
else if (word==0) {word=1; num++;}
printf ("There is%d words.\n", word);
return 0;
}
#include <stdio.h>
#pragma mark counts the number of occurrences of a string of substrings
int main ()
{
int I, j, K,count;
Char str1[20],str2[20];
printf ("Zhu Chuan:");
Gets (STR1);
printf ("Zi Chuan:");
Gets (STR2);
Count = 0;
for (i=0;str1[i];i++)
for (j=i,k=0;str1[j]==str2[k];j++,k++)
if (!str2[k+1])
count++;
printf ("Chuxian cishu=%d\n", count);
}
#pragma mark asks if an integer is a palindrome number
#include <stdio.h>
int main ()
{
Long num;
int array[10];
scanf ("%ld", &num);
int n = num, k = 0;
do {
Array[k] = n%10;
k++;
n = N/10; Completed the progression of the numbers on a single digit
} while (n!=0);
int i = 0;
int flag = 0;
for (; i< (k-1)/2; i++) {
if (array[i] = = Array[k-1-i]) {flag = 1;}
}
if (flag) {
printf ("%ld is palindrome", num);
}else{
printf ("%ld is not a palindrome", num);
}
}
C language to find the number of uppercase letters in a string, the number of words, the number of substrings and whether an integer is a palindrome number