64,637
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
int order(int, int [], int);
void print(int, int);
int main()
{
const int SIZE = 20;
int t;
int n;
int seat[SIZE] = {0};
char s='a';
for(; (s = cin.get()) != 'c'; ) // 按任意键继续,按C键结束查询
{
cout << "Please type 1 for \"smoking\" and 2 for \"no smoking\" :_\b";
cin >> t;
if(t != 1 && t != 2)
{
cout << "your input is incorrect!\n";
continue;
}
n = order(t, seat, SIZE);
print(n, t);
for(int i = 0; i < SIZE; i++)
cout << seat[i];
cout << endl;
s = cin.get();
}
return 0 ;
}
int order(int tag, int st[], int n)
{
int num;
if(tag == 1)
{
for(num= 0; num < 10; num++)
{
if(st[num] == 0)
{
break;
}
}
}
else
{
for(num=10; num < n; num++)
{
if(st[num] == 0)
{
break;
}
}
}
st[num] = 1;
return num+1;
}
void print(int x, int y)
{
if(y == 1)
{
cout << "Your seat number is " << x << " with \"smoking\" " << endl;
}
else
{
cout << "Your seat number is " << x << " with \"no smoking\" " << endl;
}
}
#include <iostream>
using namespace std;
int order(int, int [], int);
void print(int, int);
int main()
{
const int SIZE = 20;
int t;
int n;
int seat[SIZE] = {0};
char s='a';
for(; (s = cin.get()) != 'c'; ) // 按任意键继续,按C键结束查询
{
cout << "Please type 1 for \"smoking\" and 2 for \"no smoking\" :_\b";
cin >> t;
if(t != 1 && t != 2)
{
cout << "your input is incorrect!\n";
continue;
}
n = order(t, seat, SIZE);
print(n, t);
for(int i = 0; i < SIZE; i++)
cout << seat[i];
cout << endl;
s = cin.get();
}
return 0 ;
}
int order(int tag, int st[], int n)
{
int num;
if(tag == 1)
{
for(num= 0; num < 10; num++)
{
if(st[num] == 0)
{
break;
}
}
}
else
{
for(num=10; num < n; num++)
{
if(st[num] == 0)
{
break;
}
}
}
st[num] = 1;
return num+1;
}
void print(int x, int y)
{
if(y == 1)
{
cout << "Your seat number is " << x << " with \"smoking\" " << endl;
}
else
{
cout << "Your seat number is " << x << " with \"no smoking\" " << endl;
}
}
#include <iostream>
using namespace std;
int order(int, int [], int);
void print(int, int);
int main()
{
const int SIZE = 20;
int t;
int n;
int seat[SIZE] = {0};
char s='a';
for(; (s = cin.get()) != 'c'; ) // 按任意键继续,按C键结束查询
{
cout << "Please type 1 for \"smoking\" and 2 for \"no smoking\" :_\b";
cin >> t;
if(t != 1 && t != 2)
{
cout << "your input is incorrect!\n";
continue;
}
n = order(t, seat, SIZE);
print(n, t);
for(int i = 0; i < SIZE; i++)
cout << seat[i];
cout << endl;
s = cin.get();
}
return 0 ;
}
int order(int tag, int st[], int n)
{
int num;
if(tag == 1)
{
for(num= 0; num < 10; num++)
{
if(st[num] == 0)
{
break;
}
}
}
else
{
for(num=10; num < n; num++)
{
if(st[num] == 0)
{
break;
}
}
}
st[num] = 1;
return num+1;
}
void print(int x, int y)
{
if(y == 1)
{
cout << "Your seat number is " << x << " with \"smoking\" " << endl;
}
else
{
cout << "Your seat number is " << x << " with \"no smoking\" " << endl;
}
}