首页 > 其他分享 >A smart way to invert a number

A smart way to invert a number

时间:2024-02-23 14:33:05浏览次数:19  
标签:palindrome int invert number way printf array smart

/* This is my homework today to judge a number whether it's a palindrome/
/
Most of us use array to solve the problem, but I find a way do not need an array.*/

include <stdio.h>

int main(int argc, const char * argv[])
{
int x,m,n=0;
printf("Enter a number:");
scanf("%d",&x);
for(int i=1;i<=x;i=10){
m=x%(i
10)/i;
n=m+n*10;
}
if (n==x){
printf("%d is a palindrome\n",x);
}
else{
printf("%d is not a palindrome\n",x);
}

return 0;

}

标签:palindrome,int,invert,number,way,printf,array,smart
From: https://www.cnblogs.com/beshoujodaisuki/p/18029457

相关文章

  • 数据库迁移Flyway资料
    资料说明SpringBoot中使用Flyway【如果使用SpringBoot的依赖管理功能,不需要为Flyway指定版本号。】https://documentation.red-gate.com/fd/community-plugins-and-integrations-spring-boot-184127423.htmlSpringBoot中使用Flyway配置项【注意,这些配置项的名称与......
  • 解决宝塔中php项目访问502 Bad Gateway问题
    原因访问网站是nginx转发不到PHP上,宝塔上PHP通常使用监听文件的方式,文件需要写入权限解决方法:进入站点点查看nginx转发地址,发现引入了一个enable-php-74.conf文件 进入到根目录搜索enable-php-74.conf文件然后打开打开后查看转发地址,这里用的是监听文件方式最后找到这个......
  • Go - concurrent processing is not always faster than sequential processing
      ......
  • 4.3 提升题 - A One Way In, Two Ways OutC++
    就是让你判断输入受限的双端队列的输出的正确性。其实就是模拟双端队列出队的过程,要不左边出队,要不右边出队,而入队已经一定了。用一个数组模拟输入受限的双端队列就行了。但是写这题可太难受了,写了我大概2个半小时,各种各种小错误,没考虑周全的地方。#include<iostream>using......
  • [975] Creating a POSTMAN Api | AWS API Gateway Passing Data to AWS Lambda
    ref:AWSLambdaFunctionURLsref:GuidetoAWSLambdaFunctionURLs1.CreateaLambdaFunctionaws->Services->Lambda2.CreateaFunctionURLConfiguration->FunctionURLThen,theFunctionURLisgeneratedandcanbeseenfromtheup......
  • docker login 私有仓库harbor 502 Bad Gateway的报错
    具体报错:Logindidnotsucceed,error:Errorresponsefromdaemon:loginattempttohttp://harbor.com/v2/failedwithstatus:502BadGateway其实harbor在网页端是可以登录的,但是dockerlogin-uadmin-p1harbor.oldboyedu.com的时候依旧是提示报错的一般这种报错......
  • UOS下切换Wayland
    UOS下切换Wayland图形化修改方法1、下载配置策略工具sudoaptinstalldde-dconfig-editor2、进入配置工具,在greeter配置中开启wayland切换配置项:dde-dconfig-editor直接改配置文件法修改/usr/share/dsg/configs/org.deepin.dde.lightdm-deepin-greeter/org.deepin.......
  • Spring Cloud Gateway 中文文档
    SpringCloudGateway中文文档(查看原文)官方文档该项目提供了一个建立在SpringEcosystem之上的API网关,包括:Spring5,SpringBoot2和ProjectReactor。SpringCloudGateway旨在提供一种简单而有效的方式来对API进行路由,并为他们提供切面,例如:安全性,监控/指标和弹性等。1.......
  • 探索AI视频生成新纪元:文生视频Sora VS RunwayML、Pika及StableVideo——谁将引领未来
    探索AI视频生成新纪元:文生视频SoraVSRunwayML、Pika及StableVideo——谁将引领未来由于在AI生成视频的时长上成功突破到一分钟,再加上演示视频的高度逼真和高质量,Sora立刻引起了轰动。在Sora横空出世之前,Runway一直被视为AI生成视频的默认选择,尤其是自去年11月推出第二代模型以......
  • 配置springcloud 网关gateway 转发websocket请求
    网关是整个项目的统一入口这是直接访问消息服务的请求路径端口号是20007WebSocketService.init("ws://127.0.0.1:20007/ws/"+用户id)显然这样是不符合微服务的方案,所有请求必须经过网关处理,转发到各个服务之中所以我们需要在网关中的yml或者nacos中添加以下配置spring:......