n натурал (n>1) тоо болон a1, a2, . . . ,an тоонууд өгөгдсөн бол өгсөн дарааллын максимумыг олох програм
#include <stdio.h>
#include <conio.h>
main()
{ int n,a,t,k,max;
printf("\n Daraallyn gishuudiin too n= "); scanf("%d",&n);
printf("\n Daraallyn ehnii gishuunii utga= "); scanf("%d",&a);
max=a; t=1; k=1;
while (k<n)
{ k++; printf("\n%d dugeer gishuunii utga= ", k); scanf("%d",&a);
if (a>max) { max=a; t=k; }
}
printf("\n Daraallyn hamgiin ih too= %d", max);
printf(", tuunii dugaar: %d", t);
getch();
}
#include <conio.h>
main()
{ int n,a,t,k,max;
printf("\n Daraallyn gishuudiin too n= "); scanf("%d",&n);
printf("\n Daraallyn ehnii gishuunii utga= "); scanf("%d",&a);
max=a; t=1; k=1;
while (k<n)
{ k++; printf("\n%d dugeer gishuunii utga= ", k); scanf("%d",&a);
if (a>max) { max=a; t=k; }
}
printf("\n Daraallyn hamgiin ih too= %d", max);
printf(", tuunii dugaar: %d", t);
getch();
}
Comments
Post a Comment