排序
【C】判断回文数
#include <stdio.h> bool fun(int n) { int a = 0; int num = n; while (n > 0) { a = a * 10 + n % 10; n = n / 10; } if (a==num) { return true; } else { return false; } } int main() ...
【C】保留几位有效数字
使用%.6g!! 例子 #include<stdio.h> double getBMI(float m,float h){ return (m/(h*h)); } int main(){ double m,h; scanf('%lf %lf',&m,&h); float BMI=getBMI(m,h); if (BMI<...
【C】二维数组每行冒泡排序
void sort2D(int arr[][cols], int rows, int cols) { int temp; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols - 1; j++) { for (...
【C】P2415 集合求和
集合求和 题目描述 给定一个集合 s(集合元素数量 <=30),求出此集合所有子集元素之和。 输入格式 集合中的元素(元素 <=1000) 输出格式 s 所有子集元素之和。 样例 #1 样例输入 #1 2 3...
【C++】四舍五入
#include <iostream> #include <cmath> using namespace std; float a[100000]; int main(){ int n; cin >> n; for (int i=0;i<n;i++){ cin >> a[i]; } for (int i=0;i<n;i++){ cou...
【C】五舍六入?
如果题目让你五舍六入,那么就没办法使用C++里的round函数了,只能选择一个通用的方法,示例如下: #include <stdio.h> #define PI 3.1415926 int main(){ double r,ans; scanf('%lf',&r...