Commit c5e39135 by ansire

kodutoo

parent df786b8f
#include <stdio.h>
#define SUURUS 5 //prose direktiiv e makro
int main(void)
{
int arr[SUURUS];
int i, min, minIndex;
for (i=0; i<SUURUS; i++)
{
printf("Sisesta arv: ");
scanf("%d", &arr[i]);
}
min = arr[0];
minIndex = 0;
for (i=0; i<SUURUS; i++)
{
if (min>arr[i])
{
min=arr[i];
minIndex =i;
}
}
for (i=0; i<SUURUS; i++)
{
printf("%d", arr[i]);
}
printf("\n");
printf("V2him arv on %d indexil %d", min, minIndex);
return 0;
}
#include <stdio.h>
#define SUURUS_A 4
#define SUURUS_B 5
int main(void)
{
int i,j;
int laduA[SUURUS_A];
int laduB[SUURUS_B];
int laduC[SUURUS_A+SUURUS_B];
for (i=0; i<SUURUS_A; i++)
{
printf("Sisestage kaubad laost A \n");
scanf("%d", &laduA[i]);
}
for (i=0; i<SUURUS_B; i++)
{
printf("Sisestage kaubad laost B \n");
scanf("%d", &laduB[i]);
}
for (i=0;i<SUURUS_A;i++)
{
laduC[i] = laduA[i];
}
for (j=0;j<SUURUS_B;j++,i++)
{
laduC[i] = laduB[j];
}
//Siia sorteerimine laduC suurimast v2iksemaks
for (i=0; i<(SUURUS_A+SUURUS_B);i++)
{
printf("%d",laduC[i]);
}
return 0;
}
#include <stdio.h>
#define SUURUS 7
int main(void)
{
int i,j;
int orig[SUURUS];
int sorted[SUURUS];
for (i=0; i<SUURUS; i++)
{
printf("Sisestage listi element \n");
scanf("%d", &orig[i]);
}
for (i=0, j=0; i<SUURUS; i++)
{
if (orig[i]<0)
{
sorted[j] = orig [i];
j++;
}
}
for (i=0; i<SUURUS; i++)
{
if (orig[i]>=0)
{
sorted[j] = orig [i];
j++;
}
}
for (j=0;j<SUURUS;j++)
{
printf("%d\t",sorted[j]);
}
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