二道简单C语言的的题目,会的进来下

来源:百度知道 编辑:UC知道 时间:2024/07/01 13:21:01
应该挺简单的,麻烦请求会C语言的帮写下,正确再加分谢谢

1.写一个程序统计字符串中字母的个数

2.输入3个整数,按从小到大的顺输出,要求使用变量的指针做函数调用的实参来实现

#include <stdio.h>
#include <string.h>

int count(char* s,int n)
{
int i;
int j = 0;
if (s==0)
return(0);
for (i=0;i<n;i++)
if ((*(s+i)>='a' && *(s+i)<='z') || (*(s+i)>='A' && *(s+i)<='Z'))
j++;
return(j);
}

void sort(int* a, int* b, int* c)
{
int t;
if (*a>*b)
t=*a,*a=*b,*b=t;
if (*b>*c)
{
t=*b,*b=*c,*c=t;
if (*a>*b)
t=*a,*a=*b,*b=t;
}
}

main()
{
char s[255];
int a, b, c;
printf("input a string:");
scanf("%s",s);
printf("result is:\t%d\n",count(s,sizeof(s)));
printf("input a b c:");
scanf("%d%d%d",&a,&b,&c);
sort(&a,&b,&c);
printf("%d\t%d\t%d",a,b,c);
}

#include <stdio.h>
#include <stri