Commit ca5f3f6a by ansire

tunnitoo

parent c5e39135
#include <stdio.h>
#define SUURUS 5
int main(void)
{
int numbrid[SUURUS];
int rev[SUURUS];
int temp, i, j, suurus2;
suurus2=SUURUS;
for (i=0;i<SUURUS;++i)
{
printf("Sisestage suurus, mida sorteeida\n");
scanf("%d",&numbrid[i]);
}
for (i=0;i<SUURUS-1;++i)
{
for (j=0;j<suurus2-1;++j)
{
if(numbrid[j]>numbrid[j+1])
{
temp=numbrid[j];
numbrid[j]=numbrid[j+1];
numbrid[j+1]=temp;
}
}
--suurus2;
}
for (i=0;i<SUURUS;++i)
{
printf("%d\t",numbrid[i]);
}
printf("\n");
suurus2=SUURUS;
for (i=suurus2-1,j=0; i>=0;--i,++j)
{
rev[j]=numbrid[i];
}
for (i=0; i<SUURUS; ++i)
{
printf("%d\t",rev[i]);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment