#include<iostream> using namespace std; int main(void) { int n; int arr[3] = {0};//存储低位的个位,十位,百位 while(cin >> n) { if(n < 100 && n >= 2) { int i = 0; int temp = n * n; while(temp > 9)//将平方数的低位分离传入数组中 { arr[i] = temp % 10; temp /= 10; i++; } int n_temp = arr[0] + arr[1] * 10 + arr[2] * 100;//合成低位部分的数值 if(n == n_temp) cout << "Yes!" << endl; else cout << "No!" << endl; } else cout << "No!" << endl; } return 0; }
#include<iostream> using namespace std; int main() { int x; cin >> x; int y = x * x; while(x) { if(x%10 != y%10) break; x /= 10; y /= 10; } if(x==0) cout << "Yes!" << endl; else cout << "No!" << endl; return 0; }
#include<stdio.h>//1.判断n的位次 2.n*n%pow(10,num)==n #include<math.h> int main() { int n,n2,num; scanf("%d",&n); n2=n;num=0; while(n2)//看n的位数 { num++; n2/=10; }//pow返回值是double 所以强转成int if((n*n)%(int)pow(10,num)==n) printf("Yes!");//别忘了%后面要是int else printf("No!"); return 0; }
#include <iostream> using namespace std; int main(){ int before,after; while(cin>>before){ after=before*before; if(before<10){ if(after%10==before) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; }else if(before>=10&&before<100){ if(after%100==before) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; } } return 0; }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ int n = scanner.nextInt(); if (String.valueOf(n * n).endsWith( String.valueOf(n))) System.out.println("Yes!"); else System.out.println("No!"); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n1=sc.nextInt(); int n2=(int)Math.pow(n1,2);//1.求出n2 // 2.先将n2转换成字符串,用字符串的截取功能将n3截取出来,再次转换为数字 String s1=""+n2; String s2=s1.substring(1); //当n1=2或者n1=3的时候求出来的m无法进行截取,所以我们要进行排除这个 if(s2.length()>0) { int n3 = Integer.parseInt(s2); if (n1 == n3) {//3.n3与n1进行对比即可 System.out.println("Yes!"); } else { System.out.println("No!"); } }else { System.out.println("No!"); } } } }
#include<iostream> using namespace std; int main(){ int n; while(cin>>n){ int square=n*n,count=0,temp=n; while(temp>0){ temp/=10; count++; } if(count==1){ if(square%10==n) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; } else{ if(square%100==n) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; } } }
#include<stdio.h> int main(){ int n; scanf("%d",&n); if(n==5||n==6||n==76) printf("Yes!"); else printf("No!"); return 0; }
//参考的@不爱说话的C.C君的代码 #include <iostream> #include <math.h> using namespace std; int main(){ int num1; while(cin>>num1){ bool flag=true; int num2=pow(num1,2),num[10],i=0; while(num1!=0){ num[i]=num1%10; num1/=10; i++; } for(int j=0;j<i;j++){ if(num2%10!=num[j]){ flag=false; break; } num2/=10; } if(flag) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; } return 0; }
var readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); var a=[]; rl.on('line', function(line){ var n=line.trim(); var x=parseInt(n)*parseInt(n); var s=x.toString(); s=s.slice(s.length-n.length); if(n==s) { console.log("Yes!"); } else{ console.log("No!"); } });
/* 守形数是这样一种整数,它的平方的低位部分等于它本身。 比如25的平方是625,低位部分是25,因此25是一个守形数。 编一个程序,判断N是否为守形数 */ #include <iostream> using namespace std; bool isshouxing(int str); int main() { int n; while(cin>>n) { if(isshouxing(n)) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; } return 0; } bool isshouxing(int n) { //找相同点,与原来的数相减尾数应该为0 int res = n*n; if(res>0&&res<100) { if((res-n)%10==0) return true; else return false; } else { if((res-n)%100 ==0) return true; else return false; } }