请高手帮忙,计算机二级c语言题目

来源:百度知道 编辑:UC知道 时间:2024/05/30 18:57:01
编程,输入一个字符放到变量ch中,再用随机函数产生一个字符串(20个字符),统计字符串中与ch中字符相同的个数(不考虑大小写),输出字符串及统计个数。

#include<stdio.h>
#include<stdlib.h>
const cszChar[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
void main()
{
char ch;
char buf[20];//随机字符串
int i;
randomize();//初始化随机值
printf("the random string is:");
for(i=0;i<20;i++)
buf[i]=cszChar[random(52)];//随机从cszChar中取一个字符
printf("%s",buf);
printf("please iuput ch:\n");
getchar();
for(i=0;i<20;i++){
if(ch=buf[i]||ch=buf[i]+32||ch=buf[i]-32)
i++;
}
printf("there are %d letters same with ch in random string.\n");
}

你是想学C吗,那你还是自己编吧,这种程序你要写不出来,考试就难了!加油,祝你好运/1‘