idk why these stuffs get stashed for so long and I didn't ever commit them
This commit is contained in:
@@ -1,19 +1,32 @@
|
||||
#include<iostream>
|
||||
#include<iostream>//cout,cin
|
||||
using namespace std;
|
||||
|
||||
void main()
|
||||
struct stu
|
||||
{ int xh; // 学号
|
||||
float height; //身高
|
||||
};
|
||||
|
||||
int MaxH; // 最高身高
|
||||
|
||||
//算法1.1
|
||||
int maxHeight(stu student[], int n)
|
||||
{
|
||||
int i=0,j=0,count=0;
|
||||
for (i=2;i<=1000;i++)
|
||||
{
|
||||
for (j=2;j<=i-1;j++)
|
||||
if(i%j==0)
|
||||
break;
|
||||
if(j>i-1)
|
||||
{
|
||||
cout<<j<<'\t';
|
||||
count++:
|
||||
if(cout%5==0) cout<<endl;
|
||||
}
|
||||
return ;
|
||||
MaxH=1; // 1. 设第1个学生身高最高
|
||||
for (int i=2; i<=n; i++) // 2. 从第2个学生起依次与最高身比
|
||||
{
|
||||
if(student[i-1].height>student[MaxH-1].height) // 2.1 大于最高身高
|
||||
MaxH=i; // 2.2为新最高身高
|
||||
}
|
||||
return student[MaxH-1].xh; // 3.返回最高身高学生学学号
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
cout<<"获取数据"<<endl;
|
||||
int n=6; //学生数
|
||||
int xh;
|
||||
stu student[6]={{1703001,176},{1703002,180},{1703003,175},{1703004,182.5},{1703005,158.5},{1703005,173.8}};
|
||||
xh=maxHeight(student,n);
|
||||
cout<<"身高最高者是:"<<xh<<endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
void main()
|
||||
{
|
||||
int i=0,j=0,count=0;
|
||||
for (i=2;i<=1000;i++)
|
||||
{
|
||||
for (j=2;j<=i-1;j++)
|
||||
if(i%j==0)
|
||||
break;
|
||||
if(j>i-1)
|
||||
{
|
||||
cout<<j<<'\t';
|
||||
count++;
|
||||
if(count%5==0) cout<<endl;
|
||||
}
|
||||
}
|
||||
return ;
|
||||
}
|
||||
Reference in New Issue
Block a user