Untitled
unknown
plain_text
4 years ago
940 B
7
Indexable
public class Main {
public static void main(String args[]) {
String[] months = {"yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avqust", "sentyabr", "oktyabr", "noyabr", "dekabr"};
int[] prices = {2500, 2700, 1500, 6500, 1200, 7800, 1800, 6800, 3600, 8500, 6700, 3200};
int priceForFirstMonth = prices[0], priceForLastMonth = prices[1];
int max = priceForLastMonth - priceForFirstMonth;
for (int i=0; i<12; i++){
for (int j=i+1; j<12; j++){
if (max<prices[j] - prices[i]) {
priceForFirstMonth = i;
priceForLastMonth = j;
max = prices[j] - prices[i];
}
}
}
System.out.println("Alıcı səhmləri " + months[priceForFirstMonth] + " ayında alıb " + months[priceForLastMonth] + " ayında satsa, maksimum gəlir əldə edər: " + max + " AZN");
}
}Editor is loading...