#include <iostream.h>
void main()
{
cout << "輸入n:";
int n;
cin >> n;
int nCount = 0;
for (int i=1; i<n; i++)
nCount = i*i;
if (nCount > n)
nCount = (i-1)*(i-1);
break;
}
cout << "平方值不超過" << n << "的正整數: " << nCount <<endl;
/*
//如果你用的是VS2005
#include <iostream>
using namespace std;
int main()
cout<<"請輸入n的值"<<endl;
cin>>n;
for(int i=1;i<=n;i++)
if(i*i<=n) cout<<i<<"的平方不超過"<<n<<endl;
return 0;
}*/
#include <iostream.h>
void main()
{
cout << "輸入n:";
int n;
cin >> n;
int nCount = 0;
for (int i=1; i<n; i++)
{
nCount = i*i;
if (nCount > n)
{
nCount = (i-1)*(i-1);
break;
}
}
cout << "平方值不超過" << n << "的正整數: " << nCount <<endl;
}
/*
//如果你用的是VS2005
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"請輸入n的值"<<endl;
cin>>n;
for(int i=1;i<=n;i++)
{
if(i*i<=n) cout<<i<<"的平方不超過"<<n<<endl;
}
return 0;
}*/