这两题该怎么写啊,调用函数不太行

编写函数fun(),求s 共n项),a和n的值在1—9之间。例如a=3,n=5,则表达式为:s = 3+33+333+3333+33333。在主函数中输入a和n的值,通过调用fun函数完成计算。
编写一个函数count(),统计一个数中位值为零的个数以及位值为1的个数。若输入111001,则输出位值为零的个数为2,位值为1的个数为4。


#include <stdio.h>
#include <stdlib.h>
#include "math.h"


// 编写函数fun(),求s 共n项),a和n的值在1—9之间。例如a=3,n=5,则表达式为:s = 3+33+333+3333+33333。在主函数中输入a和n的值,通过调用fun函数完成计算。
void fun(int x,int y);

int main()
{

 int a,n;
  printf("请输入两个数:\n");
  scanf("%d",&a);
  scanf("%d",&n);
  fun(a,n);
  return 1;
}

//  x操作数  y项数
void fun(int x,int y)
{
   //  9999 99999   十六机制:3B9A C9FF    二进制  11 1011 1001 1010 1100 1001 1111 1111‬
   unsigned int s=0,temp=0,temp1=0,z,k,t;
   unsigned int a[y];
   if(x>0&&x<9)   //  a 取值1~9-+
   {
    /*
      a=3,n=5 s=3+33+333+3333+33333
      设输入的数为z  即s=z+zz+zzz+zzzz+zzzzz
      z+z(10+1)+z(100+10+1)+z(1000+100+10+1)+z(10000+1000+100+10+1)
      即s= z*1+z*11+z*111+z*1111+z*11111
      即s=a([10的n-1次方]+1)的递归  a为输入的操作数  n为循环次数

    */
     for(z=1;z<=y;z++)  // 每一项的
     {
        temp+=x*(pow(10,z-1));
        k=temp;
        printf("输出k:%d\n",k);
        k=0;

        s+=temp;

     }

          // printf("%d",s);
          printf("输出s:%d",s);
     }else{
     printf("输入出错请重新输入");
    }

}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/365193134966137.PNG "#left")

img

img


#include<stdio.h>
int fun(int a,int s)
{
    int i=1,j=0,sum=0,temp=0;
    while(j<s)
    {
        temp=temp+i*a;
        sum=sum+temp;
        i=i*10;
        j++;
    }
    return sum;
}
void count(int n)
{
    int a,c1=0,c2=0;
   if(n==0)
     c1++;
    while(n)
    {
        a=n%10;
        if(a==0)
           c1++;
        if(a==1)
           c2++;
        n=n/10;
    }
    printf("0:%d 1:%d",c1,c2);
}
int main()
{
    printf("%d ",fun(3,5));
    count(111001);
    return 0;
}