解题思路:
注意事项:
参考代码:
#include<iostream>
#include<iterator>
#include<stdio.h>
#include<iomanip>
#include<string>
#include<cstring>
#include<string.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
int main()
{
int n;
cin >> n;
for (int i = 1; i < n-1; i++)
{
for (int j = 1; j < n; j++)
{
int sum = (i +i-1+ j)*j / 2;
if (sum == n)
cout << i << " " << i + j - 1 << endl;//求从i开始的j项的sum,如果相等就输出,超越就跳出
else if (sum > n)
break;
}
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题6.9 (C++代码)浏览:531 |
C语言程序设计教程(第三版)课后习题8.8 (C++代码)浏览:551 |
点我有惊喜!你懂得!浏览:1069 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:939 |
钟神赛车 (C++代码)浏览:866 |
打水问题 (C语言代码)浏览:1072 |
【排队买票】 (C语言代码)浏览:900 |
WU-C语言程序设计教程(第三版)课后习题11.11 (C++代码)(想学链表的可以看看)浏览:1357 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:592 |
1024题解浏览:808 |