1 条题解
-
0
C++ :
#include <bits/stdc++.h> using namespace std; int a[110],n; int main(){ cin>>n; int i; //读入数据 for(i = 0;i < n;i++){ cin>>a[i]; } //排序 sort(a,a+n); //从大到小排序,因此逆序 reverse(a,a+n); //判断奖学金的情况 for(i = 0;i < n;i++){ if(i < 2){ cout<<a[i]<<" "<<500<<endl; }else if(i < 6){ cout<<a[i]<<" "<<300<<endl; }else if(i < 10){ cout<<a[i]<<" "<<100<<endl; }else{ cout<<a[i]<<" "<<0<<endl; } } return 0; }
Java :
import java.util.Scanner; public class Main{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n >= 10 && n <=100) { int arr[] = new int[n]; for(int i =0; i < n;i++) { arr[i] = sc.nextInt(); } printArr(sortArr(arr,n),n); } } public static int[] sortArr(int[] a,int len) { int t; for(int i = 1;i <=a.length-1;i++) { for(int j =0;j< a.length-i;j++) { if(a[j] < a[j+1]) { t = a[j]; a[j] = a[j+1]; a[j+1] = t; } } } return a; } public static void printArr(int[] a,int len) { for(int i =0; i< len;i++) { if(i == 0 || i == 1) { System.out.println(a[i] +" " + 500); }else if(i == 2 || i ==3 || i == 4 || i == 5){ System.out.println(a[i] +" " + 300); }else if(i == 6 || i ==7 || i == 8 || i == 9) { System.out.println(a[i] +" " + 100); }else { System.out.println(a[i] +" " + 0); } } } }
Python :
n=int(input()) a=list(map(int,input().split())) a=sorted(a) a.reverse() b=[0]*n js=0 for i in range(n): js=js+1 if (js<=2): b[i]=500 elif(js<=4+2): b[i]=300 elif(js<=4+2+4): b[i]=100 for i in range(n): print(a[i],b[i])
- 1
信息
- ID
- 2785
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者