Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Gee;
- class Algotitm {
- struct first {
- static int data;
- static int pos;
- }
- struct second {
- static int data;
- static int pos;
- }
- public static Algotitm() {
- }
- public static string sas(int[] mass){
- for (int i=0;i < mass.length; i++)
- if (mass[i] > first.data){
- first.data=mass[i]; first.pos = i;}
- for (int i=0;i < mass.length; i++)
- if (first.data>=mass[i] > second.data && i!=first.pos){
- second.data=mass[i]; second.pos = i;}
- int interval =(int)Math.fabs((double)(first.pos-second.pos-1));
- int summ = 0;
- for (int i = ((first.pos>second.pos)?second.pos+1:first.pos+1);
- i < ((first.pos>second.pos)?first.pos-1:second.pos-1); i++) {
- summ+=mass[i];
- print(@"$summ\n");
- }
- //int result = interval*()
- print(@"$(interval)\n");
- print(@"frst = $(first.data) firstPos = $(first.pos) sec = $(second.data) secPos = $(second.pos)");
- return "sas";
- }
- }
- void main(){
- int[] a = {1,3,0,1,2,4,2,1};
- Algotitm.sas(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement