| |

VerySource

 Forgot password?
 Register
Search
View: 992|Reply: 8

Set an integer to implement simple operations on integers

[Copy link]

3

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-16 12:30:01
| Show all posts |Read mode
class IntSet
{
private:
    vector <int> Ints;
int element [100];
int n, seeknumber;
public:
IntSet ()
{
cout << "Enter the following integer:";
cin >> n;
        for (long i = 0; i <n; i ++)
{
cin >> element [i];
Ints.push_back (element [i]);
};
cout << endl << Ints [0];
};
Empty () {Ints.clear ();};
Isempty () {if (Ints.empty ()) cout << "The collection is empty!" << endl;};
bool Ismemberof ()
{
cout << "To determine if this number is inside the collection, please enter this number:";
cin >> seeknumber;
for (long j = 0; j <n; j ++)

if (Ints [j] == seeknumber) return true;

};
Add () {};
Sub () {};
Isequal () {};
Intersection () {};
Merge () {};
Print () {};
};
Is my program correct for the title? What else is missing, I hope everyone can give me pointers below! Thank you all here!
Reply

Use magic Report

0

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-16 12:45:02
| Show all posts
std :: string ToString ();
void Print (std :: ostream&);
Intersection is the meaning of intersection? How to understand the intersection of several integers?
Does Sub mean difference? The difference in multiple numbers can be dizzy.
Does Add insert or sum? Better change name

That's about it. The landlord should straighten out the idea and rewrite an interface is better

Good luck
Reply

Use magic Report

0

Threads

22

Posts

18.00

Credits

Newbie

Rank: 1

Credits
18.00

 China

Post time: 2020-3-26 15:45:01
| Show all posts
Are Add and Sub add members and delete members?

You can add both string operations and mathematical statistics:
Number, sort, maximum, minimum, sum, mean, variance, set subtraction, set comparison ...

Good luck
Reply

Use magic Report

3

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-8 12:45:01
| Show all posts
no! The teacher said that my program is not perfect, but I don't know where it is! Is it different from the title?
Please help me discuss it.
Reply

Use magic Report

1

Threads

39

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-4-9 07:15:01
| Show all posts
achieve
operator + union
operator-poor
operator * intersection
Reply

Use magic Report

0

Threads

8

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-14 11:40:44
| Show all posts
This is an array! ? , For example, array a and array b, both arrays are recorded with array c, array a without array b is recorded with array A, array b without array a is recorded with array B
WeChat zhu299 free time research
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-6-16 10:45:02
| Show all posts
Ha ha, "element" is only used once in a function temporarily, just let it be a local variable of that function.
Reply

Use magic Report

0

Threads

14

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-6-17 22:00:02
| Show all posts
bool Ismemberof()
{
cout<<"To determine whether this number is inside the collection, please enter this number:";
cin>>seeknumber;
for (long j=0;j<n;j++)

if (Ints[j] == seeknumber) return true;
return false; // Pay attention to this sentence, should it warn when compiling?
};
Reply

Use magic Report

0

Threads

14

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-6-18 01:00:01
| Show all posts
In addition, it is best to write all the curly braces to make it clear.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list