October 2018 1 28 Report

Popraw program, który po podaniu 5 liczb przez użytkownika będzie podawał tablicę i po zmianie 2 z nich miejscami również przez użytkownika będzie podawał nową tablicę liczb po tej modyfikacji.

#include <cstdlib>
#include <iostream>
#include <conio.h>

using namespace std;

int main(int argc, char *argv[])
{
int tab[5];

for(int i=0;i<5;i++)
{
cout<<"Podaj "<<i+1<<" element tablicy :";
cin>>tab[i];
}

for(int i=0;i<5;i++)
{
cout<<tab[i]<<" ";
}

cout<<endl;

int k,l;

cout<<"Podaj numer pierwszego elementu do zamiany :";
cin>>k;

cout<<"Podaj numer drugiego elementu do zamiany :";
cin>>l;

int temp;

temp=tab[k-1];
tab[k-1]=tab[l-1];
tab[l-1]=temp;


system("PAUSE");
return EXIT_SUCCESS;
}


More Questions From This User See All

Recommend Questions



Life Enjoy

" Life is not a problem to be solved but a reality to be experienced! "

Get in touch

Social

© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.