求出从m到n之间的所有的自守数,并且按照每行5个整数,如何用C++编程?

来源:百度知道 编辑:UC知道 时间:2024/06/08 09:51:09

#include<iostream>
using namespace std;
int fun(int m,int n)
{
int count=0;
for(long i=m;i<=n;i++)
{
if(i>0&&i<=9)
{
int temp1=i*i;
int temp2=temp1%10;
if(i==temp2)
{
count++;
cout<<i<<"*"<<i<<"="<<i*i<<" ";
if(count%5==0)
cout<<endl;
}
}
if(i>=10&&i<=99)
{
int temp3=i*i;
int temp4=temp3%100;
if(i==temp4)
{
count++;
cout<<i<<"*"<<i<<"="<<i*i<<" ";
if(count%5==0)
cout<<endl;
}
}
if(i>=100&&i<=999)
{