Commit 878cd712 by glkink

Add new file

parent b98bc339
Showing with 89 additions and 0 deletions
//
//
// Created by Glen Kink on 09.11.2021.
//
#include <stdio.h>
#include <string.h>
int main(void)
{
int i,j,sonadeArv;
printf("Sisesta sonade arv\n");
scanf("%d", &sonadeArv);
char sonad[sonadeArv][20];
int massiiv[sonadeArv];
printf("Sisesta %d sona:", sonadeArv);
for(i = 0; i < sonadeArv; i++)
{
scanf("%s", sonad[i]);
}
for(i = 0; i < sonadeArv; i++)
{
int r = strlen(sonad[i]);
int min = 0;
int max = 0;
if(r < 2)
{
massiiv[i] = 0;
continue;;
}
for (j = 0; j < r-1; j++)
{
if (sonad[i][j] > sonad[i][j + 1])
{
min++;
}
if (sonad[i][j] < sonad[i][j + 1])
{
max++;
}
}
if(min == 0 && max != 0)
{
massiiv[i] = 2;
}
else if(max == 0 && min != 0)
{
massiiv[i] = 3;
}
else
{
massiiv[i] = 1;
}
}
for (i = 0; i < sonadeArv; i++)
{
printf("Sona %s ",sonad[i]);
switch (massiiv[i])
{
case 0:
printf("liiga luhike");
break;
case 1:
printf("pole sorditud");
break;
case 2:
printf("sorditud kahanevalt");
break;
case 3:
printf("sorditud kahanevalt");
break;
default:
printf(" ");
break;
}
printf("\n");
}
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