📄 app.cpp
字号:
#include <iostream>
#include <string>
using namespace std;
struct germBox
{
int a;
int b;
int c;
};
int main()
{
string sample[100];
char * s = new char[100];
int count=0;
germBox * Box = new germBox[100];
germBox temp;
germBox * First = new germBox[100];
int first=0;
germBox * Second = new germBox[100];
int second=0;
bool flag = false;
int * box = new int[300];
//int * originNum = new int[100];
//int * nowNum = new int[100];
cout<<"培养皿个数:"<<endl;
cin>>count;
cout<<"培养皿的情况,一行代表一个培养皿:"<<endl;
cin.sync();//清空输入缓存
for(int i=0;i<count;i++)
{
getline(cin,sample[i]);
}
//string转换为int数组
for(int j=0,boxNum=0;j<count;j++)
{
//cout<<"第"<<count<<"个:"<<sample[i]<<endl;
s = (char *)sample[j].c_str();
for(int k=0,start=0,end=0;k<sample[j].length()+1;k++)
{
if((s[k]-'0')==-16||(s[k]-'0')==-48)
{
//cout<<"空格"<<endl;
end = k;
box[boxNum] = 0;
while(start<end)
{
box[boxNum] = box[boxNum]*10+(s[start]-'0');
start++;
}
boxNum++;
start++;
}
//else
//cout<<s[j]<<endl;
}
}
/*测试输出
for(int i=0;i<count*3;i++)
{
cout<<box[i]<<endl;
}
*/
for(int t=0;t<count;t++)
{
Box[t].a = box[3*t];
Box[t].b = box[3*t+1];
Box[t].c = box[3*t+2];
}
//Box = this.BubbleSort(Box,count);
//冒泡排序
for(int y=0;y<count;y++)
{
flag = false;
for(int u=count-1;u>i;u--)
if(Box[u].c<Box[u-1].c)
{
temp = Box[u];
Box[u] = Box[u-1];
Box[u-1] = temp;
flag = true;
}
if(!flag)
break;
}
//按种类排序
for(int r=0,o=0,p=0;r<count;r++)
{
if(Box[r].c/Box[r].b<100)
{
Second[o] = Box[o];
o++;
second = o;
}
else
{
First[p] = Box[r];
p++;
first = p;
}
}
//for(int i=0;i<count;i++)
// cout<<Box[i].a<<endl;
for(int h=0;h<first;h++)
cout<<First[h].a<<endl;
for(int q=0;q<second;q++)
cout<<Second[q].a<<endl;
system("pause");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -