编程之美之加法的面试题
2014-05-17 23:33
323 查看
#include<iostream>
#include
#include
using namespace std;
void func(int m)
{
int flag=1;
for(int i=2;i
{
if(i%2==0&&(m-i/2)%i==0)
{
//for(int j=m/i-(i/2-1);j
// cout<<j<<"+";
//cout<<j<<"="<<m<<endl;
flag=0;
break;
}
else if(i%2==1&&m%i==0)
{
//for(int k=m/i-i/2;k
// cout<<k<<"+";
//cout<<k<<"="<<m<<endl;
flag=0;
break;
}
}
if(flag==1)
cout<<m<<endl;
}
int main()
{int temp;
cin>>temp;
for(int i=1;i<99999;i++)
func(i);
int n= clock();
cout<<n<<endl;
return 0;
}
#include
#include
#include
using namespace std;
int func(int m)
{
int count=0;
for(int i=2;i
{
if(i%2==0&&(m-i/2)%i==0)
{
//for(int j=m/i-(i/2-1);j
// cout<<j<<"+";
//cout<<j<<"="<<m<<endl;
count++;
}
if(i%2==1&&m%i==0)
{
//for(int k=m/i-i/2;k
// cout<<k<<"+";
//cout<<k<<"="<<m<<endl;
count++;
}
}
return count;
}
int main()
{ int temp=0;int temp2=0;
for(int i=1;i<99;i++)
{
if(temp
{
temp=func(i);
temp2=i;
}
}
cout<<temp2<<":"<<temp<<endl;
int n= clock();
cout<<n<<endl;
return 0;
}
#include
#include
using namespace std;
void func(int m)
{
int flag=1;
for(int i=2;i
{
if(i%2==0&&(m-i/2)%i==0)
{
//for(int j=m/i-(i/2-1);j
// cout<<j<<"+";
//cout<<j<<"="<<m<<endl;
flag=0;
break;
}
else if(i%2==1&&m%i==0)
{
//for(int k=m/i-i/2;k
// cout<<k<<"+";
//cout<<k<<"="<<m<<endl;
flag=0;
break;
}
}
if(flag==1)
cout<<m<<endl;
}
int main()
{int temp;
cin>>temp;
for(int i=1;i<99999;i++)
func(i);
int n= clock();
cout<<n<<endl;
return 0;
}
#include
#include
#include
using namespace std;
int func(int m)
{
int count=0;
for(int i=2;i
{
if(i%2==0&&(m-i/2)%i==0)
{
//for(int j=m/i-(i/2-1);j
// cout<<j<<"+";
//cout<<j<<"="<<m<<endl;
count++;
}
if(i%2==1&&m%i==0)
{
//for(int k=m/i-i/2;k
// cout<<k<<"+";
//cout<<k<<"="<<m<<endl;
count++;
}
}
return count;
}
int main()
{ int temp=0;int temp2=0;
for(int i=1;i<99;i++)
{
if(temp
{
temp=func(i);
temp2=i;
}
}
cout<<temp2<<":"<<temp<<endl;
int n= clock();
cout<<n<<endl;
return 0;
}
相关文章推荐
- 编程之美 2.21 只考加法的面试题
- 编程之美--只考加法的面试题1
- 编程之美--只考加法的面试题
- 【编程之美】2.21 只考加法的面试题
- 编程之美-只考加法的面试题
- 编程之美 -- 只考虑加法的面试题,程序理解和分析
- 编程之美只有加法的面试题
- 编程之美-只考加法的面试题整理
- 编程之美---只考加法的面试题
- 编程之美----2.21 只考加法的面试题
- 读书笔记之编程之美 - 2.21 只考加法的面试题
- 考查C++/C程序员的基本编程技能面试题
- 《编程之美》--只有加法的面试题
- 只考加法的面试题
- C++面试题之编程风格面试题
- 程序员面试题精选100题(55)-不用+、-、×、÷数字运算符做加法
- [原]编程之美2.21 只考加法的面试题
- C/C++面试题:编程实现快速排序
- 蛇形矩阵的打印;开拓思路与设计方法的面试题;编程技巧比较巧妙;转自CSDN论坛;
- 考查C++/C程序员的基本编程技能面试题