import java.util.*;
public class schoolgoonas
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int a, b, c, d;
int pa = 0, pb = 0, pc = 0, pd = 0;
int p;
System.out.print("Number of students from Section 1 : ");
a = in.nextInt();
System.out.print("Number of students from Section 2 : ");
b = in.nextInt();
System.out.print("Number of students from Section 3 : ");
c = in.nextInt();
System.out.print("Number of students from Section 4 : ");
d = in.nextInt();
for (int section = 1; section <= 4; section++)
{
int count = 0;
if (section == 1) count = a;
if (section == 2) count = b;
if (section == 3) count = c;
if (section == 4) count = d;
for (int i = 1; i <= count; i++)
{
System.out.print("Enter Section " + section + " student percentage : ");
p = in.nextInt();
if (p >= 95)
{
if (section == 1) pa++;
if (section == 2) pb++;
if (section == 3) pc++;
if (section == 4) pd++;
}
}
}
System.out.println("tudents scoring 95% and above:");
System.out.println("Section 1 : " + pa);
System.out.println("Section 2 : " + pb);
System.out.println("Section 3 : " + pc);
System.out.println("Section 4 : " + pd);
}
}
Latest from community today
# Hello World! program in Python
def say_hello():
print ('Hello, World')
for i in range(5):
say_hello()
Any guesses? Yes, its an automated system created by hte one who balances the universe and that energy resides in all of us. So the whole that you see, you hear you experience is all already planned by the superior and one can't erase his plans and replan so I just navigate through the entire journey believing in god and god's plans.
# Simple Interest Calculator
def simple_interest(principal, rate, time):
"""
Function to calculate simple interest.
Formula: SI = (P * R * T) / 100
"""
si = (principal * rate * time) / 100
return si
def main():
print("===== Simple Interest Calculator =====")
# Taking inputs from user
try:
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest (%): "))
time = float(input("Enter the time (in years): "))
# Calculate simple interest
si = simple_interest(principal, rate, time)
total = principal + si
# Display results
print("\n------ Result ------")
print(f"Principal Amount : ₹{principal:.2f}")
print(f"Rate of Interest : {rate:.2f}%")
print(f"Time Period : {time:.2f} years")
print(f"Simple Interest : ₹{si:.2f}")
print(f"Total Amount : ₹{total:.2f}")
except ValueError:
print("Error: Please enter valid numeric values.")
# Run the program
if __name__ == "__main__":
main()
# Данные рангов экспертов (каждый подсписок - оценки одного эксперта)
ranks = [
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[1, 10, 2, 3, 4, 5, 7, 6, 8, 9],
[6, 1, 10, 2, 4, 7, 9, 3, 5, 8],
[6, 3, 10, 5, 1, 8, 9, 2, 4, 7],
[3, 1, 9, 2, 10, 4, 6, 5, 7, 8],
[1, 2, 6, 3, 4, 5, 8, 7, 9, 10],
[1, 2, 5, 4, 3, 6, 8, 7, 9, 10],
[10, 8, 9, 6, 2, 5, 7, 1, 4, 3],
[2, 7, 9, 3, 6, 10, 5, 1, 4, 8],
[2, 8, 9, 3, 6, 10, 5, 1, 4, 7]
]
# Названия мессенджеров
messengers = {
1: "WhatsApp",
2: "WeChat",
3: "FB Messenger",
4: "Telegram",
5: "Snapchat",
6: "QQ",
7: "Line",
8: "Discord",
9: "Zalo",
10: "Momo"
}
num_messengers = len(messengers)
num_experts = len(ranks)
# 1. Суммарные ранги
total_ranks = {messengers[i+1]: 0 for i in range(num_messengers)}
for expert_ratings in ranks:
for i, rating in enumerate(expert_ratings):
total_ranks[messengers[i+1]] += rating
print("Суммарные ранги по мессенджерам:")
for messenger, total in total_ranks.items():
print(f"{messenger}: {total}")
# 2. Метод Кондорсе — создание матрицы парных сравнений
pairwise_matrix = [[0]*num_messengers for _ in range(num_messengers)]
for i in range(num_messengers):
for j in range(num_messengers):
if i == j:
continue
count = 0
for expert in ranks:
if expert[i] < expert[j]:
count += 1
pairwise_matrix[i][j] = count
print("\nМатрица парных сравнений (число экспертов, предпочитающих строку столбцу):")
header = "\t" + "\t".join(messengers[i+1] for i in range(num_messengers))
print(header)
for i in range(num_messengers):
row_name = messengers[i+1]
row = []
for j in range(num_messengers):
if i == j:
row.append("-")
else:
row.append(str(pairwise_matrix[i][j]))
print(f"{row_name}\t" + "\t".join(row))
# Дополнительное — таблица отношений в виде 0/1
relation_matrix = [['-' if i == j else 0 for j in range(num_messengers)] for i in range(num_messengers)]
for i in range(num_messengers):
for j in range(num_messengers):
if i == j:
continue
if pairwise_matrix[i][j] > pairwise_matrix[j][i]:
relation_matrix[i][j] = 1
else:
relation_matrix[i][j] = 0
print("\nТаблица отношений (0/1), где 1 — мессенджер строки побеждает у столбца:")
print(header)
for i in range(num_messengers):
row_name = messengers[i+1]
row = [str(relation_matrix[i][j]) for j in range(num_messengers)]
print(f"{row_name}\t" + "\t".join(row))
# Подсчет побед каждого мессенджера по Кондорсе
condorcet_wins = [0]*num_messengers
for i in range(num_messengers):
for j in range(num_messengers):
if i == j:
continue
if pairwise_matrix[i][j] > pairwise_matrix[j][i]:
condorcet_wins[i] += 1
max_wins = max(condorcet_wins)
condorcet_winners = [messengers[i+1] for i, wins in enumerate(condorcet_wins) if wins == max_wins]
print("\nКоличество побед в парных сравнениях по методу Кондорсе:")
for i in range(num_messengers):
print(f"{messengers[i+1]}: {condorcet_wins[i]}")
print(f"\nЛучший мессенджер по методу Кондорсе: {', '.join(condorcet_winners)} (побед в парах: {max_wins})")
# 3. Метод Борда
# Баллы = n - ранг + 1, где n — количество мессенджеров
borda_scores = {messengers[i+1]: 0 for i in range(num_messengers)}
for expert_ratings in ranks:
for i, rank in enumerate(expert_ratings):
score = num_messengers - rank + 1 # обратный ранг
borda_scores[messengers[i+1]] += score
print("\nБаллы по методу Борда:")
for messenger, score in borda_scores.items():
print(f"{messenger}: {score}")
max_borda = max(borda_scores.values())
borda_winners = [m for m, s in borda_scores.items() if s == max_borda]
print(f"\nЛучший мессенджер по методу Борда: {', '.join(borda_winners)} (баллов: {max_borda})")import java.io.*;
import java.util.*;
/*
* To execute Java, please define "static void main" on a class
* named Solution.
*
* If you need more classes, simply define them inline.
*/
class Solution {
public static void main(String[] args) {
ArrayList<String> strings = new ArrayList<String>();
strings.add("Hello, World!");
strings.add("Running Java " + Runtime.version().feature());
for (String string : strings) {
System.out.println(string);
}
}
}function add(a, b) {
return a + b;
}
function subtract(a, b) {
return a - b;
}
function multiply(a, b) {
return a * b;
}
function divide(a, b) {
if (b === 0) {
return "Error: Division by zero!";
}
return a / b;
}
// Example usage:
let num1 = 10;
let num2 = 5;
console.log("Addition:", add(num1, num2));
console.log("Subtraction:", subtract(num1, num2));
console.log("Multiplication:", multiply(num1, num2));
console.log("Division:", divide(num1, num2));class Solution {
public ListNode mergeKLists(ListNode[] lists) {
if(lists.length<1) {
return null;
}
ListNode result = new ListNode(Integer.MIN_VALUE);
for(int i=0; i<lists.length; i++) {
// method from previous question
mergeTwoLists(result, lists[i]);
}
return result.next;
}
}
