- 博客(4)
- 问答 (1)
- 收藏
- 关注
原创 冒泡排序(升序)
回想起来大学第一学期学的C语言中的冒泡排序,依然没有忘记那一年期末考试面对冒泡排序因为没有真正理解而导致的手足无措。今天我就想再按自己现在的想法理解写一遍冒泡排序。 原理 (从小到大)相邻的两个数进行比较,如果前一个数大于后一个数,即进行交换。这样进行直至数据从小到大排列。 过程分析 例:输入六个 30,24,150,-7,56,98 第一轮排序 六个数进行5次比较 1 比较:30>24,30与24交换位置,变换为 2 2 比较:30<150,30与150不交...
2021-09-25 20:40:16
1098
原创 1001:Sum Problem(方法2)
方法1已经输入一遍题了,懒得copy题目了。 方法一是直接求和,方法二是用的等差数列的公式。 我的简单思维: #include <iostream> using namespace std; int main() { int n,sum; while (cin >> n) { sum = (1 + n)*n / 2; cout << sum << "\n" << endl; } sum = 0; } 乍一看,我又.
2021-09-22 21:35:43
68
原创 1001:Sum Problem(方法1)
Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each ca..
2021-09-22 21:03:55
83
原创 1000:Calculate A + B
这是我在杭电OJ写的第一道题,记录一下写题的过程。 Description CalculateA + B. Input Each line will contain two integersAandB. Process to end of file. 多组测试数据,每组测试数据占一行,包括2个整数。 Output For each case, outputA + Bin one line. #include<iostream> using namespa...
2021-09-22 20:10:05
264
空空如也
重装win10系统遇到了问题
2022-02-23
TA创建的收藏夹 TA关注的收藏夹
TA关注的人