import java.util.*;
class Student
{
int number;
String name,sex,bangan;
///boolean bangan;
float m,c,e,sum,ave;
void Input()
{
Scanner scan=new Scanner(System.in);
number=scan.nextInt();
name=scan.next();
sex=scan.next();
bangan=scan.next();
m=scan.nextFloat();
c=scan.nextFloat();
e=scan.nextFloat();
}
float sums()
{
return (m+c+e);
}
float aves()
{
return (sums()/3);
}
}
public class Main {
public static void main(String[] args) {
Student zs=new Student();
System.out.println("请输入学生信息(格式:学号 姓名 性别 是否班干 数学分数 语文分数 外语分数)");
zs.Input();
System.out.println("该学生的信息为:");
System.out.println("姓名:"+zs.name);
System.out.println("性别:"+zs.sex);
System.out.println("是否班干:"+zs.bangan);
System.out.println("数学:"+zs.m);
System.out.println("语文:"+zs.c);
System.out.println("外语:"+zs.e);
System.out.println("总分:"+zs.sums());
System.out.println("平均分:"+zs.aves());
}
}
输入:1403 张三 男 是 78 79 80
import java.util.*;
class Trans
{
int[][] transpose(int [][]c)
{
int [][]d=new int[c[0].length][c.length];
int i,j;
for(i=0;i<c.length;i++)
{
for(j=0;j<c[i].length;j++)
{
d[j][i]=c[i][j];
}
}
return d;
}
}
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int m,n;
m=scan.nextInt();
n=scan.nextInt();
int [][]a=new int[m][n];
int [][]ta=new int[n][m];
int []b=new int[m];
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=scan.nextInt();
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
b[i]+=a[j][i];
}
}
System.out.println("各列之和分别为:");
for(i=0;i<n;i++)
{
System.out.print(b[i]+" ");
}
System.out.println("\n转置之后为");
Trans pose=new Trans();
ta=pose.transpose(a);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
System.out.print(ta[i][j]+" ");
}
System.out.println();
}
}
}
class Student
{
int number;
String name,sex,bangan;
///boolean bangan;
float m,c,e,sum,ave;
void Input()
{
Scanner scan=new Scanner(System.in);
number=scan.nextInt();
name=scan.next();
sex=scan.next();
bangan=scan.next();
m=scan.nextFloat();
c=scan.nextFloat();
e=scan.nextFloat();
}
float sums()
{
return (m+c+e);
}
float aves()
{
return (sums()/3);
}
}
public class Main {
public static void main(String[] args) {
Student zs=new Student();
System.out.println("请输入学生信息(格式:学号 姓名 性别 是否班干 数学分数 语文分数 外语分数)");
zs.Input();
System.out.println("该学生的信息为:");
System.out.println("姓名:"+zs.name);
System.out.println("性别:"+zs.sex);
System.out.println("是否班干:"+zs.bangan);
System.out.println("数学:"+zs.m);
System.out.println("语文:"+zs.c);
System.out.println("外语:"+zs.e);
System.out.println("总分:"+zs.sums());
System.out.println("平均分:"+zs.aves());
}
}
输入:1403 张三 男 是 78 79 80
import java.util.*;
class Trans
{
int[][] transpose(int [][]c)
{
int [][]d=new int[c[0].length][c.length];
int i,j;
for(i=0;i<c.length;i++)
{
for(j=0;j<c[i].length;j++)
{
d[j][i]=c[i][j];
}
}
return d;
}
}
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int m,n;
m=scan.nextInt();
n=scan.nextInt();
int [][]a=new int[m][n];
int [][]ta=new int[n][m];
int []b=new int[m];
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=scan.nextInt();
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
b[i]+=a[j][i];
}
}
System.out.println("各列之和分别为:");
for(i=0;i<n;i++)
{
System.out.print(b[i]+" ");
}
System.out.println("\n转置之后为");
Trans pose=new Trans();
ta=pose.transpose(a);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
System.out.print(ta[i][j]+" ");
}
System.out.println();
}
}
}