C语言程序题高手谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/16 01:14:04
1. 比较两个字符串大小关系,第一个字符串大输出“大”;第二个字符串大输出“小”;相等输出“等”
2. 从键盘输入一行字符,分别统计其中大小写字母字符和数字字符的个数并输出。

C语言库里面有专门的函数啊
可以直接利用

这不是c语言的作业吗。如果这是你的作业都不自己做,以后要用的时候再学就爽了。而且这个好简单啊,你就if比较一下ASCⅡ码就行了,在书的后面有列表。第二题一样,三个int来存储大小写及数字的个数,再通过就行了ASCⅡ码判断输入的是什么,相应的int进行++操作就行了。

第一题:
#include <stdio.h>
#include <string.h>
void main()
{
char*p=new char[30];
char*q=new char[30];
printf("please input first string\n");
gets(p);
printf("please input second string\n");
gets(q);
while((*p)&&(*q)&&(*p==*q))
{
p++;q++;
}
int s=*p-*q;
if (s==0)
printf("相同");
if (s>0)
printf("大于");
if (s<0)
printf("小于");

}

第二题:
#include<stdio.h>
void main()
{
char a[30],*ps;
int i=0,j=0,l=0,m=0;
printf("please input a string\n");
gets(a);
ps=a;
while(*ps)
{
if((*ps>='a')&&(*ps<='z')) <