C语言代码:计算汽车速度和下一个对称里程数
#include<stdio.h>
int main(){
int i=95859;//初始对称数
while(1){//无限循环
i++;//递增取值
int a=i/10000;//分解出万位数
int b=(i/1000)%10;//分解出千位数
int c=(i/100)%10;//分解出百位数
int d=(i/10)%10;//分解出十位数
int e=i%10;//分解出个位数
if(a==e&&b==d&&a==9){//判断对称数是否为9xxxx9
printf("%.2f\n",(float)i/2-95859);//输出速度
printf("%d",i);//输出新的对称数
break;//跳出循环
}
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/n7Da 著作权归作者所有。请勿转载和采集!