29
Algoritm
1.
Familiya kiritilishini so„rash.
2.
Kiritilgan familiya uzunligini o„lchash.
3.
Familiya oxirgi va oxiridan 1 ta
oldingi simvolini tekshirish, ya‟ni
familiya oxiri “
ev
”
bilan tugasa, satrning oxirgi 3 ta simvolini o„chirish va
7-qadamga o„tish, aks holda 4-qadamga o„tish.
4.
Familiya oxirgi va oxiridan 1 ta oldingi simvolini tekshirish, ya‟ni
familiya oxiri “
ov
” bilan tugasa, satrning oxirgi 2 ta simvolini o„chirish va
7-qadamga o„tish, aks holda 5-qadamga o„tish.
5.
Familiya oxirgi va oxiridan 2 ta oldingi simvolini tekshirish, ya‟ni
familiya oxiri “
eva
” bilan tugasa, satrning oxirgi 4 ta simvolini o„chirish va
7-qadamga o„tish, aks holda 6 qadamga o„tish.
6.
Familiya oxirgi va oxiridan 2 ta oldingi simvolini tekshirish, ya‟ni
familiya oxiri “
ova
” bilan tugasa, satrning oxirgi 3 ta simvolini o„chirish va
7-qadamga o„tish.
7.
Hosil bo„lgan ismni ekranga chiqarish.
Talabalar algoritmni so„z bilan yoki blok-sxema ko„rinishida
ifodalashlari
mumkin.
Dastur kodi
:
#include
#include
using namespace std;
int main(){
int l;
char a[100];
cout << " Familiyani kiriting: ";
gets(a);
l=strlen(a);
if(a[l-1] == 'v' && a[l-2] == 'e'){ l = l-3; }