int main(int argc,char *argv[]){
int N,n,s
printf("Please enter N(int 0<N<10)...\nN=")
if(scanf("%d",&N)!=1 || N<1 || N>9){
printf("Input error, exit...\n")
return 0
}
while(N--){
printf("\nPlease enter n(int 0<n<李握山200)...\nn=")
while(scanf("%d",&n)!=1 哪中|| n<1 || n>199){
printf("Input error, redo: ")
fflush(stdin)
}
for(s=0n>0s+=n--)
printf("s 皮悉= %d\n",s)
}
return 0
}
运行们例:
#include<stdio.h>#include<孙唤string.h>则扰凯李局
int digit(int n, int k)
{
int count = 0
int t
while(k)
{
t = n%10
n = n/10
k--
}
return t
}
int main(void)
{
int n,k
int num
scanf("%d%d",&n,&k)
num = digit(n,k)
printf("digit<%d,%d>= %d\n",n,k,num)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)