Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

C++

#include <iostream.h>
void main()
{
cout<< C++;
}

cin
// cin
#include <iostream.h>
void main()
{
int var1;
cout<< :
cin>>var1;
cout<<\n<<T : <<2*var1;


void main()
{
int var1;
// var1
int sum;
// sum
var1 = 10;
// var1
int var2 = 2*var1; //
var2
sum = var1 + var2; // sum
cout<< <<sum;


#include <iostream>
void main()
{
//
float rad ; // float
const float PI=3.14; // float
//
cout<< ;
cin>> rad ;

//
float embado = PI * rad * rad ;
cout<< "= "<< embado << endl;
}

for

for(counter=1;counter<=10;counter++)
{
cout << The counter is = << counter <<endl;
}
while(I >=1){
cout << \n You are inside loop-while ;
--;
}

1
:

+, -, * /

.


#include <iostream>
using namespace std;
int main()
{
int sum, min, pol, diair;
int x = 8;
int y = 0;
sum=x+y;
min=x-y;
pol=x*y;
if (y==0)
cout << " den ginetai h diairesi
\n";

else{
diair=x/y;
cout << " diair " << diair;}
cout << " sum "<< sum <<"\n";
cout << " min " << min <<"\n";
cout << " pol " << pol <<"\n";

system("pause");
return 0;
}

#include <iostream>
using namespace std;
int main()
{
int n;
int prime = 1;
cout << "dwse ena arithmo
megalutero tou 0:\n";
cin >> n;
while (n<1){
cout << "dwse ena arithmo
megalutero tou 0:\n";
cin >> n;
}
for (int j=2; j<n; j++)
{
if (n % j == 0)

{
prime = 0;
break;
}
}
if (prime==0)
cout << " o arithmos "<< n << "
den einai prwtos\n";
else
cout << " o arithmos "<< n << "
einai prwtos\n";
system("pause");

return 0;
}

,
.

#include <iostream>
using namespace std;
int main(){
int n;
cout << "Dwse arithmo"<< "\n ;
cin >> n;
while(n!= 123)
{
cout << "den petuxes" << "\n ";
cout << " Xanaprospathise" <<"\n ";
cin >> n;
}
cout << "Bravo! ton vrikes "<<"\n ";
system("pause");
return 0;
}


selection sort

insertion sort
bubble sort

P[0]

P[1]

P[2]

54

10

for (i=0; i<N-1; i++)

{
k = i;
min = p[i];
for (j = i+1; j<N; j++)
{
if (p[j] < min)
{
k = j;
min = p[j];

1 0

min

if (p[j] < k
min)

54

10

10<54

10<3

10

10>54
oxi

}
p[k] = p[i] ;
p[i] = min;

2 1
1


Insertion Sort

:
, ,
,
, .

P[0]

P[1]

P[2]

54

10

P[0]

P[1]

P[2]

10

54

P[0]

P[1]

P[2]

10

54

P[0]

P[1]

P[2]

10

54

p[j+1] =
p[j] ;

j = j-1 ;

j = i-1;

while (x
< p[j])

p[j+1] =
x;
P[0]=10

for (i=1; i<=N; i++) {


x = p[i];
p[0] = x;
j = i-1;
while (x < p[j])
{
p[j+1] = p[j] ;
j = j-1 ;

}
p[j+1] = x ;

}
i

1
2

x=
p[i];

p[0]
= x;

10

10

10<54

P[1]=54

-1

P[0]=3

3<54

P[2]=54

3<10

P[1]=10

-1

P[0]=3

You might also like