判断是否是素数回文数
判断是否素数
for(int j = 2;j < number / 2; j++)
{
if(number % j == 0)
return false;
}
returnm ture;
判断是否是回文数
int n = 0,count = 0,num1 = num;
while(num1 > 0){
n = n * 10 + num1 % 10; ///重要算法 n表示倒过来的数
num1 = num1 / 10;
}
if(n == num)
return true;
else
return false;
#include<iomanip> 头文件中的setw(int n)
用法cout <<setw(6)<<k<<endl; 或cout <<setw(6)<<k; 表示给k 6个空格的分配空间
n是在输出时分配了n个字符的输出宽度,然后默认的是在n个字符宽度中右对齐输出,可以使用setiosflags(iOS::left)设置为左对齐输出,
可以使用setfill('char x')使用x来填充空下的空格
cout << setw(10) << setiosflags(ios::left) <<setfill('*') << 10 << endl;
cout << setw(10) << setiosflags(ios::right) <<setfill('*') << 10 << endl;
cout << setw(10) << setfill('*') << 10 << endl;