#include <stdio.h>
int fun(int n,int i)
{
int a,b,c,d,s;
s = n;
if(i == 0)
{
a=s/1000;
return a;
}
if(i == 1)
{
b=s/100;
return b;
}
if(i == 2)
{
c=s/10;
return c;
}
if(i == 3)
{
d=s/1;
return d;
}
}
void main()
{
int num1=1489,i=0;
for(i = 0; i <= 3; i++)
{
printf("%d\n",fun(num1,i));
}
}
这个看得明白了吧
int fun(int n,int i)
{
int a,b,c,d,s;
s = n;
if(i == 0)
{
a=s/1000;
return a;
}
if(i == 1)
{
b=s/100;
return b;
}
if(i == 2)
{
c=s/10;
return c;
}
if(i == 3)
{
d=s/1;
return d;
}
}
void main()
{
int num1=1489,i=0;
for(i = 0; i <= 3; i++)
{
printf("%d\n",fun(num1,i));
}
}
这个看得明白了吧