6371

DeRucci

joylie
yxc
benno0812

import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
while(true)
{
int n = sc.nextInt();  //这句定义语句一定不要提前写，不然会少一次输入
if(n==0) break;
for(int i=0;i<n;i++)
{
for(int j = 0;j<n;j++)
{
System.out.printf("%d ",Math.abs(i-j)+1);
}
System.out.println();
}
System.out.println();
}
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), m = sc.nextInt();
int [][] res = new int [n][m];
int [] dx = {-1,0,1,0};
int [] dy = {0,1,0,-1};
int x = 0, y = 0, d = 1; //注意一开始的坐标，左上角是x=0，y=0
//向下是x正方向，向右是y正方向，d=0就是y正，d=1是x正，d=2是y负，d=3是x负
//另外，变换方向顺序为0->1->2->3->0->1->2->3,变换方向的触发条件需要注意
for(int i = 1;i<=n*m;i++)
{
res[x][y] = i;  //注意这里是res[x][y]=1;而不是res[m][n] =1;
int a = x + dx[d], b = y + dy[d];
if(a<0||a>=n||b<0||b>=m || res[a][b]>0)  //注意这里五个条件
{
d = (d+1)%4;
a = x + dx[d];
b = y + dy[d];
}
x = a;
y = b;
}
for(int[] row:res)
{
for(int val: row) //一定要注意这行不是int[] val
{
System.out.printf("%d ",val);
}//对于每一行的从第一列到最后一列
System.out.println();
}
// for(int i =0;i<n;i++){
//     for(int j =0;j<n;j++)
//     {
//         System.out.printf("%d ", res[i][j]);
//     }
//     System.out.println();

}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double [][] q = new double[12][12];
String op = sc.next();
double sum = 0;
int num =0;

for(int i =0;i<12;i++)
for(int j =0;j<12;j++)
q[i][j] = sc.nextDouble();
//获取参数
for(int i = 0;i<12;i++)
for(int j = 0;j<11-i;j++)
{
sum += q[i][j];
num +=1;
}

//三角的逻辑关系，这里就是主要部分
if("S".equals(op)) System.out.printf("%.1f",sum);
if("M".equals(op)) System.out.printf("%.1f",(double)sum/num);
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double[][] q = new double[12][12];
double sum =0;
int num =0;
String op = sc.next();
for(int i =0;i<12;i++)
for(int j =0;j<12;j++)
q[i][j] = sc.nextDouble();
for(int i = 0;i<12;i++)
for(int j = i+1;j<12;j++)
{
sum += q[i][j]; num+=1;
}
if("S".equals(op)) System.out.printf("%.1f", sum);
if("M".equals(op)) System.out.printf("%.1f",sum/num);  //注意这里的num是元素个数,
//不是上一题的12了
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double[][] m = new double[12][12];
int l = sc.nextInt();
String c = sc.next();
for(int i =0;i<12;i++) //为二维数组赋值
{
for(int j = 0;j<12;j++)
{
m[i][j] = sc.nextDouble();
}
}

if("S".equals(c))
{
double sum= 0;
for(int i = 0;i<12;i++)
{
sum+= m[l][i];
}
System.out.printf("%.1f\n",sum);
}
if("M".equals(c))
{
double sum= 0;
for(int i = 0;i<12;i++)
{
sum += m[l][i];
}
System.out.printf("%.1f\n",sum/12.0);
}
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double []a = new double[100];
for(int i =0;i<100;i++)
a[i] = sc.nextDouble();
for(int i =0;i<100;i++)
{
if(a[i]<=10) System.out.printf("A[%d] = %.1f\n", i ,a[i]);
}
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int v = sc.nextInt();
int[] a = new int[10];
a[0] = v;
for(int i =1;i<10;i++)
a[i] = 2*a[i-1];
for(int i =0;i<10;i++)
System.out.printf("N[%d] = %d\n",i,a[i]);
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int[] a = new int[10];
for(int i = 0; i<10;i++)
a[i] = sc.nextInt();
for(int i = 0;i<10;i++)
{
if(a[i] <=0) a[i] =1;
}
for(int i =0; i<10;i++)
{
System.out.printf("X[%d] = %d\n",i,a[i]);
}
}
}


import java.util.Scanner; //做这个题很显然卡到了
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
long [] arr = new long[61];
arr[0] = 0;
arr[1] = 1;
for(int i = 2;i <= 60;i++) //这里首先求出来
{
arr[i] = arr[i-1] + arr[i-2];  //不是a[x] =a[x-1]+a[x-2]
}
while(t>0)
{
int n = sc.nextInt();
System.out.printf("Fib(%d) = %d\n", n, arr[n]);
t--;
}
}
}


import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = 0, b= 1;
for(int i = 0;i<n;i++)
{
System.out.printf("%d ",a);
int c = a+b;
a = b;
b = c;
}
}
}