急急急!!!设计c语言的程序啊 。具体见补充说明哦。。

来源:百度知道 编辑:UC知道 时间:2024/06/03 16:02:22
第一题的题目是:输入两个正整数m和n,秋其最大公约数和最小公约数。第二题是 输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。

第一题:C语言程序代码:
#include<stdio.h>
int main()
{ int m, n;
int m_cup, n_cup, res; /*被除数, 除数, 余数*/
printf("Enter two integer:\n");
scanf("%d %d", &m, &n);
if (m > 0 && n >0)
{ m_cup = m;
n_cup = n;
res = m_cup % n_cup;
while (res != 0)
{ m_cup = n_cup;
n_cup = res;
res = m_cup % n_cup;
}
printf("Greatest common divisor: %d\n", n_cup);
printf("Lease common multiple : %d\n", m * n / n_cup);
}
else printf("Error!\n");
return 0;
}

第二题:
#include<stdio.h>
void main()
{
int a,b,c,d;
a=0,b=0,c=0,d=0;
char m;
while((m=getchar())!='\n')
{
if(('a'<=m&&m<='z')||('A'<=m&&m<='Z'))a=a+1;
else if(m==' ')b=b+1;
else if('0'<=m&&m<=