How to add, remove and show element in table with indicators with C++











up vote
0
down vote

favorite












I'm new with C++ and have problem with indicators



#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int * createTab(int size)
{
int * wskTab;
wskTab = new int [size];
return wskTab;
}
void fill(int * mytab, int size)
{
for(int i=0;i<size;i++) {
mytab[i]= rand()%(38-16)+16;
}
}
void show(int * mytab, int size)
{
for(int i=0;i<size;i++) {
coud<<mytab[i]<<"";
}
cout<<endl;
}
int * addElem(int size, int * mytab, int val)
{
int * nwsk = new int [size+1);
for (int i = 0; i<size ;i++) {
nwski[i] = mytab[i];
}
delete mytab;}
nwsk[size] = val;
return nwsk;
}
int * removeElem (int size, int * mytab, int id)
{
int * nwsk = new int [size -1];
for(int i = ; i < id; i++) {
nwski[i] = mytab[i];
}
for (int i = id+1; i < size; i++) {
nwski[i-1] = mytab[i];
}
delete mytab;
return nwsk;
}


And now, how to:




  1. Add element inside

  2. Remove first and last element of table

  3. Show piece of table

  4. Upgrade piece of table










share|improve this question
























  • Why are you not using std::vector<int> instead of new and delete? Looking at your code, you're trying to accomplish the same thing as 3 or 4 lines of C++ using std::vector would accomplish.
    – PaulMcKenzie
    8 hours ago












  • Also, your formatting makes the code very hard to read. You should properly indent your code, instead of having all the statements start flush on the left margin.
    – PaulMcKenzie
    8 hours ago










  • PaulMcKenzie i need to do this for school. I don't know how to use command vector.
    – Maciek Łuczyński
    8 hours ago










  • vector is not a command. It is what is used in C++ as a dynamic array. Thus your entire createTab function is std::vector<int> workTab(size);
    – PaulMcKenzie
    7 hours ago








  • 1




    You're new to C++, but you're being asked to code this way? Get another teacher. Removing, adding elements is 1 line of code for each, without bugs, mistakes, memory leaks, etc. What you're being taught is C with some C++ syntax thrown in.
    – PaulMcKenzie
    7 hours ago

















up vote
0
down vote

favorite












I'm new with C++ and have problem with indicators



#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int * createTab(int size)
{
int * wskTab;
wskTab = new int [size];
return wskTab;
}
void fill(int * mytab, int size)
{
for(int i=0;i<size;i++) {
mytab[i]= rand()%(38-16)+16;
}
}
void show(int * mytab, int size)
{
for(int i=0;i<size;i++) {
coud<<mytab[i]<<"";
}
cout<<endl;
}
int * addElem(int size, int * mytab, int val)
{
int * nwsk = new int [size+1);
for (int i = 0; i<size ;i++) {
nwski[i] = mytab[i];
}
delete mytab;}
nwsk[size] = val;
return nwsk;
}
int * removeElem (int size, int * mytab, int id)
{
int * nwsk = new int [size -1];
for(int i = ; i < id; i++) {
nwski[i] = mytab[i];
}
for (int i = id+1; i < size; i++) {
nwski[i-1] = mytab[i];
}
delete mytab;
return nwsk;
}


And now, how to:




  1. Add element inside

  2. Remove first and last element of table

  3. Show piece of table

  4. Upgrade piece of table










share|improve this question
























  • Why are you not using std::vector<int> instead of new and delete? Looking at your code, you're trying to accomplish the same thing as 3 or 4 lines of C++ using std::vector would accomplish.
    – PaulMcKenzie
    8 hours ago












  • Also, your formatting makes the code very hard to read. You should properly indent your code, instead of having all the statements start flush on the left margin.
    – PaulMcKenzie
    8 hours ago










  • PaulMcKenzie i need to do this for school. I don't know how to use command vector.
    – Maciek Łuczyński
    8 hours ago










  • vector is not a command. It is what is used in C++ as a dynamic array. Thus your entire createTab function is std::vector<int> workTab(size);
    – PaulMcKenzie
    7 hours ago








  • 1




    You're new to C++, but you're being asked to code this way? Get another teacher. Removing, adding elements is 1 line of code for each, without bugs, mistakes, memory leaks, etc. What you're being taught is C with some C++ syntax thrown in.
    – PaulMcKenzie
    7 hours ago















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm new with C++ and have problem with indicators



#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int * createTab(int size)
{
int * wskTab;
wskTab = new int [size];
return wskTab;
}
void fill(int * mytab, int size)
{
for(int i=0;i<size;i++) {
mytab[i]= rand()%(38-16)+16;
}
}
void show(int * mytab, int size)
{
for(int i=0;i<size;i++) {
coud<<mytab[i]<<"";
}
cout<<endl;
}
int * addElem(int size, int * mytab, int val)
{
int * nwsk = new int [size+1);
for (int i = 0; i<size ;i++) {
nwski[i] = mytab[i];
}
delete mytab;}
nwsk[size] = val;
return nwsk;
}
int * removeElem (int size, int * mytab, int id)
{
int * nwsk = new int [size -1];
for(int i = ; i < id; i++) {
nwski[i] = mytab[i];
}
for (int i = id+1; i < size; i++) {
nwski[i-1] = mytab[i];
}
delete mytab;
return nwsk;
}


And now, how to:




  1. Add element inside

  2. Remove first and last element of table

  3. Show piece of table

  4. Upgrade piece of table










share|improve this question















I'm new with C++ and have problem with indicators



#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int * createTab(int size)
{
int * wskTab;
wskTab = new int [size];
return wskTab;
}
void fill(int * mytab, int size)
{
for(int i=0;i<size;i++) {
mytab[i]= rand()%(38-16)+16;
}
}
void show(int * mytab, int size)
{
for(int i=0;i<size;i++) {
coud<<mytab[i]<<"";
}
cout<<endl;
}
int * addElem(int size, int * mytab, int val)
{
int * nwsk = new int [size+1);
for (int i = 0; i<size ;i++) {
nwski[i] = mytab[i];
}
delete mytab;}
nwsk[size] = val;
return nwsk;
}
int * removeElem (int size, int * mytab, int id)
{
int * nwsk = new int [size -1];
for(int i = ; i < id; i++) {
nwski[i] = mytab[i];
}
for (int i = id+1; i < size; i++) {
nwski[i-1] = mytab[i];
}
delete mytab;
return nwsk;
}


And now, how to:




  1. Add element inside

  2. Remove first and last element of table

  3. Show piece of table

  4. Upgrade piece of table







c++ tabular






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 4 hours ago









Brian Tompsett - 汤莱恩

4,153133699




4,153133699










asked 8 hours ago









Maciek Łuczyński

132




132












  • Why are you not using std::vector<int> instead of new and delete? Looking at your code, you're trying to accomplish the same thing as 3 or 4 lines of C++ using std::vector would accomplish.
    – PaulMcKenzie
    8 hours ago












  • Also, your formatting makes the code very hard to read. You should properly indent your code, instead of having all the statements start flush on the left margin.
    – PaulMcKenzie
    8 hours ago










  • PaulMcKenzie i need to do this for school. I don't know how to use command vector.
    – Maciek Łuczyński
    8 hours ago










  • vector is not a command. It is what is used in C++ as a dynamic array. Thus your entire createTab function is std::vector<int> workTab(size);
    – PaulMcKenzie
    7 hours ago








  • 1




    You're new to C++, but you're being asked to code this way? Get another teacher. Removing, adding elements is 1 line of code for each, without bugs, mistakes, memory leaks, etc. What you're being taught is C with some C++ syntax thrown in.
    – PaulMcKenzie
    7 hours ago




















  • Why are you not using std::vector<int> instead of new and delete? Looking at your code, you're trying to accomplish the same thing as 3 or 4 lines of C++ using std::vector would accomplish.
    – PaulMcKenzie
    8 hours ago












  • Also, your formatting makes the code very hard to read. You should properly indent your code, instead of having all the statements start flush on the left margin.
    – PaulMcKenzie
    8 hours ago










  • PaulMcKenzie i need to do this for school. I don't know how to use command vector.
    – Maciek Łuczyński
    8 hours ago










  • vector is not a command. It is what is used in C++ as a dynamic array. Thus your entire createTab function is std::vector<int> workTab(size);
    – PaulMcKenzie
    7 hours ago








  • 1




    You're new to C++, but you're being asked to code this way? Get another teacher. Removing, adding elements is 1 line of code for each, without bugs, mistakes, memory leaks, etc. What you're being taught is C with some C++ syntax thrown in.
    – PaulMcKenzie
    7 hours ago


















Why are you not using std::vector<int> instead of new and delete? Looking at your code, you're trying to accomplish the same thing as 3 or 4 lines of C++ using std::vector would accomplish.
– PaulMcKenzie
8 hours ago






Why are you not using std::vector<int> instead of new and delete? Looking at your code, you're trying to accomplish the same thing as 3 or 4 lines of C++ using std::vector would accomplish.
– PaulMcKenzie
8 hours ago














Also, your formatting makes the code very hard to read. You should properly indent your code, instead of having all the statements start flush on the left margin.
– PaulMcKenzie
8 hours ago




Also, your formatting makes the code very hard to read. You should properly indent your code, instead of having all the statements start flush on the left margin.
– PaulMcKenzie
8 hours ago












PaulMcKenzie i need to do this for school. I don't know how to use command vector.
– Maciek Łuczyński
8 hours ago




PaulMcKenzie i need to do this for school. I don't know how to use command vector.
– Maciek Łuczyński
8 hours ago












vector is not a command. It is what is used in C++ as a dynamic array. Thus your entire createTab function is std::vector<int> workTab(size);
– PaulMcKenzie
7 hours ago






vector is not a command. It is what is used in C++ as a dynamic array. Thus your entire createTab function is std::vector<int> workTab(size);
– PaulMcKenzie
7 hours ago






1




1




You're new to C++, but you're being asked to code this way? Get another teacher. Removing, adding elements is 1 line of code for each, without bugs, mistakes, memory leaks, etc. What you're being taught is C with some C++ syntax thrown in.
– PaulMcKenzie
7 hours ago






You're new to C++, but you're being asked to code this way? Get another teacher. Removing, adding elements is 1 line of code for each, without bugs, mistakes, memory leaks, etc. What you're being taught is C with some C++ syntax thrown in.
– PaulMcKenzie
7 hours ago



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343748%2fhow-to-add-remove-and-show-element-in-table-with-indicators-with-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343748%2fhow-to-add-remove-and-show-element-in-table-with-indicators-with-c%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy