c语言编程题 ,大家帮帮忙,很急,谢谢了啊

37. 假设字符数组存放有三行字符,每行的长度最长为80个字符,编程:分别统计出其中大写字母、小写字母、数字字符、空格字符以及其它字符的个数。49. 编一子程序实现十进制数转换为其它进制数。主程序将十进制数43 和17分别转换为二进制数和八进制数。51. 编程输入一个整数,若为四位正整数则要求正确分离出其个、十、百、千位及中间的两位数并分别输出,如输入的是1234,则输出应该为4、3、2、1、23;否则给出一个出错提示。

输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
1.程序分析:利用while语句,条件为输入的字符不为'\n'.
      
2.程序源代码:
#include "stdio.h"
#include "conio.h"
main()
{
char c;
int letters=0,space=0,digit=0,others=0;
printf("please input some characters\n");
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,
space,digit,others);
getch();
}

八进制转换为十进制
1.程序分析:           
2.程序源代码:
#include "stdio.h"
#include "conio.h"
main()
{
char *p,s[6];int n;
p=s;
gets(p);
n=0;
while(*(p)!='\0')
{
n=n*8+*p-'0';
p++;
}
printf("%d",n);
getch();
}

给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。
1. 程序分析:学会分解出每一位数,如下解释:(这里是一种简单的算法,师专数002班赵鑫提供)
2.程序源代码:
#include "stdio.h"
#include "conio.h"
main( )
{
long a,b,c,d,e,x;
scanf("%ld",&x);
a=x/10000;/*分解出万位*/
b=x%10000/1000;/*分解出千位*/
c=x%1000/100;/*分解出百位*/
d=x%100/10;/*分解出十位*/
e=x%10;/*分解出个位*/
if (a!=0) printf("there are 5, %ld %ld %ld %ld %ld\n",e,d,c,b,a);
else if (b!=0) printf("there are 4, %ld %ld %ld %ld\n",e,d,c,b);
else if (c!=0) printf(" there are 3,%ld %ld %ld\n",e,d,c);
else if (d!=0) printf("there are 2, %ld %ld\n",e,d);
else if (e!=0) printf(" there are 1,%ld\n",e);
getch();
}
大概的要用的的一些东西 都有了 你自己在这上面分析下,估计能做出来 你要做的东西了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-09-27
太多了 ·········也没点加分
第2个回答  2011-09-30
我也想知道 嘿嘿!
相似回答