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

Create Ex07_14.cpp #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions 201816040116/Ex07_14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#include<iomanip>
#include<vector>
using namespace std;
int main()
{
vector<int>c; //创建数组
int a,d=0,i,j,k,b=0;
for(j=1;j<=20;j++)
{
cin>>a; //给a赋值
if(a>=10&&a<=100) //判定是否为有效数字
{
for(k=0;k<d;k++) //与数组已有数值进行比较
{
if(a==c[k])
b=1; //是否重复的标志
}
if(b==0) //若不重复则赋予数组值
{
c.push_back(a);d++;
}
else
{ b=0; } //如果重复则不赋予数组数值
}
else
continue;
}
for(i=0;i<c.size();i++)
cout<<c[i]<<" "; //输出数组中数据
return 0;
}