chap0808  0809_职场//8.8写一函数,输入一个四位数字,要求输出这四个数字字符,但每两个数字间空格。如输入1990,应输出"1_9_9_0"。
chap0808  0809_职场
chap0808  0809_职场
chap0808  0809_职场#include <stdio.h>
chap0808  0809_职场void main()
chap0808  0809_职场{
chap0808  0809_职场    int a;
chap0808  0809_职场    int temp1,temp2,temp3,temp4;
chap0808  0809_职场    printf("请输入一个四位数:");
chap0808  0809_职场    scanf("%d",&a);
chap0808  0809_职场    temp1 = a/1000;//千位数
chap0808  0809_职场    if (temp1 == 0) {
chap0808  0809_职场     printf("不是一个四位数");
chap0808  0809_职场    }
chap0808  0809_职场    else{
chap0808  0809_职场    printf("%d ",temp1);}
chap0808  0809_职场
chap0808  0809_职场    temp2 =(a-temp1*1000)/100;//百位数
chap0808  0809_职场    printf("%d ",temp2);    
chap0808  0809_职场    temp3 = (a-temp1*1000-temp2*100)/10 ;//十位数
chap0808  0809_职场    printf("%d ",temp3);    
chap0808  0809_职场    temp4 = a%10 ;//个位数
chap0808  0809_职场    printf("%d\n ",temp4);    
chap0808  0809_职场    
chap0808  0809_职场}
 
 
 
chap0808  0809_休闲_26//8.9编写一函数,由实参传来一个字符串,统计此字符串中字母、数字、空格和其它字符的个数,在主函数中输入字符串以及输出上述结果。    
chap0808  0809_休闲_26
chap0808  0809_休闲_26#include <stdio.h>
chap0808  0809_休闲_26#include <string.h>
chap0808  0809_休闲_26
chap0808  0809_休闲_26void tongji( char str0[100] ,int b[4])
chap0808  0809_休闲_26{
chap0808  0809_休闲_26  int i,n;
chap0808  0809_休闲_26        n = strlen(str0);
chap0808  0809_休闲_26     for(i = 0;i < n+1;i++)
chap0808  0809_休闲_26     {    
chap0808  0809_休闲_26     if(str0[i]>=65&&str0[i]<=90||str0[i]>=97&&str0[i]<=122)
chap0808  0809_休闲_26        b[0]++;    
chap0808  0809_休闲_26     else if(str0[i]>=48&&str0[i]<=57)    
chap0808  0809_休闲_26        b[1]++;    
chap0808  0809_休闲_26     else if(str0[i]==32)
chap0808  0809_休闲_26        b[2]++;    
chap0808  0809_休闲_26     else b[3]++;
chap0808  0809_休闲_26     }
chap0808  0809_休闲_26    
chap0808  0809_休闲_26     printf("数字个数:%d\n",b[0]);    
chap0808  0809_休闲_26     printf("字母个数:%d\n",b[1]);    
chap0808  0809_休闲_26     printf("空格个数:%d\n",b[2]);    
chap0808  0809_休闲_26     printf("其余个数:%d\n",b[3]);    
chap0808  0809_休闲_26}
chap0808  0809_休闲_26
chap0808  0809_休闲_26
chap0808  0809_休闲_26void main()
chap0808  0809_休闲_26{
chap0808  0809_休闲_26    
chap0808  0809_休闲_26     char str[100];
chap0808  0809_休闲_26        int b[4]={0};
chap0808  0809_休闲_26     gets(str);
chap0808  0809_休闲_26     tongji(str ,b);
chap0808  0809_休闲_26
chap0808  0809_休闲_26}
 
 
在main里面 若果使用tongji(str0[100],b[4])则出错
cannot convert parameter 1 from 'char' to 'char []'
 
 
why??/