头像

NobleFire

同济大学




离线:4小时前


最近来访(67)
用户头像
Lin_Yinjia
用户头像
Expelliarmus2011
用户头像
切尔西
用户头像
mayu666
用户头像
寻觅梦
用户头像
tyjz_yyds
用户头像
link_null
用户头像
风不会停息_6
用户头像
Jack404
用户头像
天梯蒟蒻
用户头像
杂毛小猪
用户头像
AcWing2AK
用户头像
V1
用户头像
WangJY
用户头像
zztt
用户头像
赤瞳
用户头像
长风_52
用户头像
千秋Q
用户头像
slight
用户头像
cdm

活动打卡代码 AcWing 756. 蛇形矩阵

NobleFire
5小时前
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int m = cin.nextInt();
        int q[][] = new int [n][m];
        int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
        int l = 1;
        for(int k = 1, i = 0, j = 0; k <= n * m; k ++){
                q[i][j] = k;
                int x = i + dx[l], y = j + dy[l];
                if(x < 0 || x >= n || y < 0 || y >= m || q[x][y] != 0){
                    l = (l + 1) % 4;
                    x = i + dx[l]; y = j + dy[l];
                }
                i = x; j = y;
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++) 
                System.out.print(q[i][j] + " ");
            System.out.println(" ");
        }
    }
}




NobleFire
6小时前
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        char op = cin.next().charAt(0);
        double sum = 0;
        for(int j = 0; j < 12; j ++)
            for(int k = 0; k < 12; k ++){
                double x = cin.nextDouble();
                if(k < 12 - j - 1) sum += x;
            }
        if(op == 'S') System.out.printf("%.1f", sum);
        else System.out.printf("%.1f", sum / 66);
    }
}




NobleFire
6小时前

java 代码

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        int q[][] = new int [105][105];
        for(int n = 0; n < 105; n++){
            int x = cin.nextInt();
            if(x == 0) break;
            for(int m = 0; m <= x / 2; m ++)
                for(int j = m; j < x - m; j ++)
                    for(int k = m; k < x - m; k ++)
                        q[j][k] = m + 1;
            for(int i = 0; i < x; i++){
                for(int j = 0; j < x; j++)
                    System.out.printf("%d ", q[i][j]);
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



活动打卡代码 AcWing 753. 平方矩阵 I

NobleFire
6小时前
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner cin = new Scanner(System.in);
        int q[][] = new int [105][105];
        for(int n = 0; n < 105; n++){
            int x = cin.nextInt();
            if(x == 0) break;
            for(int m = 0; m <= x / 2; m ++)
                for(int j = m; j < x - m; j ++)
                    for(int k = m; k < x - m; k ++)
                        q[j][k] = m + 1;
            for(int i = 0; i < x; i++){
                for(int j = 0; j < x; j++)
                    System.out.printf("%d ", q[i][j]);
                System.out.println("");
            }
            System.out.println("");
        }
    }
}



活动打卡代码 AcWing 743. 数组中的行

NobleFire
16小时前
import java.util.*;
public class Main{
    public static void main(String[] arg) {
      Scanner cin = new Scanner(System.in);
      double q[][] = new double[12][12]; 
      int l = cin.nextInt();
      String s = cin.next();
      for(int i = 0; i < 12; i ++) {
          for(int j = 0; j < 12; j++){
              q[i][j] = cin.nextDouble();
          }
      }
      double y = 0;
      for(int i = 0; i < 12; i++)  y += q[l][i];
      if(s.equals("S"))  System.out.printf("%.1f",y);
      else  System.out.printf("%.1f",y/12);
   }
}


活动打卡代码 AcWing 737. 数组替换

NobleFire
18小时前
import java.util.*;
public class Main{
    public static void main(String[] arg){
      Scanner cin = new Scanner(System.in);
      int q[] = new int[10];  
      for(int i = 0; i < 10; i ++) {
          int x = cin.nextInt();
          if(x <= 0) x = 1;
          q[i] = x;
          System.out.printf("X[%d] = %d\n", i, q[i]);
      }
    }
}


活动打卡代码 AcWing 708. 偶数

NobleFire
18小时前
import java.util.*;
public class Main{
    public static void main(String[] arg){

      for(int i = 2; i <= 100; i += 2)
         System.out.println(i);

    }
}


活动打卡代码 AcWing 665. 倍数

NobleFire
18小时前
import java.util.*;
public class Main{
    public static void main(String[] arg){
        Scanner cin = new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        if(a % b == 0 || b % a == 0) System.out.println("Sao Multiplos");
        else System.out.println("Nao sao Multiplos");

    }
}


活动打卡代码 AcWing 3477. 简单排序

NobleFire
20小时前
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int n, q[N];


int main()
{
    cin >> n;
    for (int i = 1; i <= n; i ++ ) cin >> q[i];
    sort(q, q + 1 + n);
    for (int i = 1; i <= n; i ++ )
        if(q[i] != q[i - 1])  cout << q[i] << " ";
    return 0;
}


活动打卡代码 AcWing 653. 钞票

import java.util.*;

public class Main{
    public static void main(String[] arg){
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        System.out.println(N);
        int q[] = {100, 50, 20, 10, 5, 2, 1};
        for(int i = 0; i < 7; i ++){
             System.out.printf("%d nota(s) de R$ %d,00\n", N / q[i], q[i]);
             N = N % q[i];
        }
    }
}