Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Create Ex07_13.cpp" #99

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions 201816040208/Ex07_13.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <array>

using namespace std;

int main()
{
array <int, 20> a;
int i = 0, j = 0, k;
int n; //每次输入的数值
int flag; //判定输入的数是否与之前二点重复

for(i = 0; i < 20; i++)
{
flag = 1;
cin >> n; //输入数值
if(n < 10 || n > 100)
{
cout << "The data entered is invalid!" << endl << "Please enter again:";
i--; //若输入数值不符合要求,则重新输入
continue;

}

for(k = 0; k < j; k++)
{
if(a[k] == n)
flag = 0; //若数值与之前的重复,则不放进数组里
}

if(flag)
a[j++] = n;
}

for(i = 0; i < j; i++)
cout << a[i] << " "; //输出


return 0;
}
47 changes: 47 additions & 0 deletions 201816040208/Ex07_14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <iostream>
#include <vector>

using namespace std;

int main()
{
vector< int > a( 0 );
int i, j, k = 0;
int n; //每次输入的数值
int flag; //判断是否重复

for(i = 0; i < 20; i++)
{
cin >> n; //输入数值
flag = 1;
if(n < 10 || n > 100)
{
cout << "The data entered is invalid!" << endl << "Please enter again:";
i--; //若输入数值不符合要求,则重新输入
continue;

}

for(j = 0; j < k; j++)
{
if(a[j] == n)
{
flag = 0; //输入数字与之前重复
break;
}

}

if(flag)
{
a.push_back(n); //将数放入vector数组中
k++;
}
}

for(i = 0; i < k; i++)
{
cout << a[i] << " "; //输出
}
return 0;
}
40 changes: 40 additions & 0 deletions 201816040208_/Ex07_13.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <array>

using namespace std;

int main()
{
array <int, 20> a;
int i = 0, j = 0, k;
int n; //每次输入的数值
int flag; //判定输入的数是否与之前二点重复

for(i = 0; i < 20; i++)
{
flag = 1;
cin >> n; //输入数值
if(n < 10 || n > 100)
{
cout << "The data entered is invalid!" << endl << "Please enter again:";
i--; //若输入数值不符合要求,则重新输入
continue;

}

for(k = 0; k < j; k++)
{
if(a[k] == n)
flag = 0; //若数值与之前的重复,则不放进数组里
}

if(flag)
a[j++] = n;
}

for(i = 0; i < j; i++)
cout << a[i] << " "; //输出


return 0;
}
41 changes: 0 additions & 41 deletions 201816040317/Ex07_13.cpp

This file was deleted.

32 changes: 0 additions & 32 deletions 201816040317/Ex07_14

This file was deleted.

32 changes: 0 additions & 32 deletions 201816040317/Ex07_14.cpp

This file was deleted.