C语言求解程序改错
#include<conio.h>#include<stdio.h>main(){longs,t,sl=10;clrscr();printf("\nPleaseenter...
#include <conio.h> #include <stdio.h> main( ) { long s, t, sl=10; clrscr(); printf("\nPlease enter s:"); scanf("%ld", &s); /************found************/ t = s / 10; while ( s > 0) { s = s/100; t = s%10 * sl + t; /************found************/ sl = sl*100; } printf("The result is: %ld\n", t); }
展开
1个回答
展开全部
#include <conio.h>
#include <stdio.h>
main( )
{
long s, t, sl=10;
clrscr();
printf("\nPlease enter s:");
scanf("%ld", &s);
/************found************/
/* 原代码错误 t = s / 10;*/
t = s % 10;
while ( s > 0)
{
s = s/100;
t = s%10 * sl + t;
/************found************/
/* 原代码错误 sl = sl*100;*/
sl = sl*10;
}
printf("The result is: %ld\n", t);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询