📄 app.cpp
字号:
#include<stdio.h>
#include "iostream"
#include "string"
#include <math.h>
using namespace std;
void max(double *a,double *b){
if(*a<*b){
double c;
c=*a;
*a=*b;
*b=c;
}
}
void pop(double *n22,int count){
for(int i=0;i<count;i++){
for(int j=count-1;j>i;j--){
max((n22+j-1),(n22+j));
}
}
}
double myabs(double d){
if(d<0){
return -d;
}else {
return d;
}
}
string tobig(double *n,int count,double avg){
double n2[100];
double *n22;
for(int i=0;i<count;i++){
n2[i] = myabs(*(n+i)-avg);
}
n22 = n2;
pop(n22,count);
//cout << *n22 << endl;
for(int j=0;j<count;j++){
if(myabs(*(n+j)-avg)==*n22){
cout << *(n+j) << ",";
}
}
cout << endl;
return "";
}
void main(){
while(true){
int count=1;
cout << "input count" << endl;
cin >> count;
double *mynumber;
double my[100];
cout << "input number" << endl;
for(int i=0;i<count;i++){
cin >> my[i];
}
mynumber = my;
double avg = 0;
double all=0;
for(int j=0;j<count;j++){
double a = *(mynumber+j);
all = all+a;
}
avg = all/count;
//cout << avg << endl;
tobig(mynumber,count,avg);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -