matlab作业 编程画图 求大神解答

233 2024-03-08 09:29

一、matlab作业 编程画图 求大神解答

不一定很准确局埋,但基本要素应该齐全了:

syms 巧侍x

f=x*sin(x);

I=int(f);

x=0:0.1:4;

[ax, h1, h2] = 孝腊吵plotyy(x,subs(f),x,subs(I),@stem,@plot);

set(h1, 'linewidth', 2)

set(h2, 'linewidth', 1.5)

axes(ax(1))

text(0.5,1.5,'\fontsize{13}\ity=xsinx')

ylabel('被积函数 \ity=xsin(x)')

axes(ax(2))

ylabel('\fontsize{13}\its=\int_0^{ x}xsinxdx')

text(2.5,3.3,'\fontsize{13}\its=\int_0^{ x}xsinxdx')

二、C语言编程作业,急!!!!

#include stdio.h

#include <string.h>

struct tel{

char name[11],num[11];

};

int main(int argc,char *argv[]){

struct tel s[50];

int n,i;

char t[]=############;

printf(Please enter n(int 猜腔0<n<51)...\n);

if(scanf(%d,&n)!=1 || n<1 || n>50){

printf(Input error, exit...\n);

return 0;

}

printf(Enter 兄野some name and tel-number(by ' ','Enter' end)...\n);

for(i=0;i<羡兆喊n;i++)

scanf(%10s%*[^0-9]%10s,s[i].name,s[i].num);

printf(------------------------\n);

for(i=0;i<n;i++)

printf(%.*s%s%.*s%s\n,12-strlen(s[i].name),t,s[i].name,12-strlen(s[i].num),t,s[i].num);

return 0;

}

运行样例:

#include<stdio.h>

#include<string.h>

struct

{

char name[32],tel[32];

}t,bks[50];

int main()

{

int i,j,len,n;

scanf(%d,&n);

for(i=0;i<n;i++)

scanf(%s %s,bks[i].name,bks[i].tel);

for(i=0;i<n-1;i++)

{

for(j=0;j<n-1-i;j++)

{

if(strcmp(bks[j].name,bks[j+1].name)>0)

{

t=bks[j];

bks[j]=bks[j+1];

bks[j+1]=t;

}

}

}

for(i=0;i<n;i++)

{

len=strlen(bks[i].name);

len=(len<=10 ? len : 10);

bks[i].name[len]='\0';

len=strlen(bks[i].tel);

len=(len<=10 ? len : 10);

bks[i].tel[len]='\0';

printf(%12s%12s\n,bks[i].name,bks[i].tel);

}

return 0;

}

三、JAVA编程作业

网上找的,你试试能用吗

public class Student implements Comparable{

public Student(String no, String name) {

this.no = no;

this.name = name;

}

public Student() {

}

public Student(String no, String name, double english, double maths,

double computer, double sum) {

this.no = no;

this.name = name;

this.english = english;

this.maths = maths;

this.computer = computer;

this.sum = sum;

}

private String no;

private String name;

private double english;

private double maths;

private double computer;

private Double sum=0.0;

public String getNo() {

return no;

}

public void setNo(String no) {

this.no = no;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getEnglish() {

return english;

}

public void setEnglish(double english) {

this.english = english;

sum+=english;

}

public double getMaths() {

return maths;

}

public void setMaths(double maths) {

this.maths = maths;

sum+=maths;

}

public double getComputer() {

return computer;

}

public void setComputer(double computer) {

this.computer = computer;

sum+=computer;

}

public Double getSum() {

return sum;

}

public void setSum(Double sum) {

this.sum = sum;

}

public String toString() {

return 学号:+no+姓名+name+英语+english+数学+maths+计算机+computer+总成绩+sum;

}

public int compareTo(Object o) {

return sum.compareTo(((Student)o).getSum());

}

public Double sum(){

return english+maths+computer;

}

public Double testScore(){

return sum/3;

}

}

public class StudentXW extends Student{

public StudentXW(String no, String name) {

super(no,name);

}

public StudentXW() {

super();

}

private String duty;

public String getDuty() {

return duty;

}

public void setDuty(String duty) {

this.duty = duty;

}

public Double testScore() {

return super.testScore()+3;

}

}

public class StudentBZ extends Student{

public StudentBZ(String no, String name) {

super(no,name);

}

public StudentBZ() {

super();

}

private String duty;

public String getDuty() {

return duty;

}

public void setDuty(String duty) {

this.duty = duty;

}

public Double testScore() {

return super.testScore()+5;

}

}

public class Test {

public static void main(String[] args) {

Student student1=new Student(001,1);

student1.setEnglish(60.0);

student1.setMaths(60.0);

student1.setComputer(60.0);

System.out.println(student1+测试成绩是+student1.testScore());

Student student2=new StudentXW(002,2);

student2.setEnglish(70.0);

student2.setMaths(70.0);

student2.setComputer(70.0);

System.out.println(student2+测试成绩是+student2.testScore());

Student student3=new StudentBZ(003,3);

student3.setEnglish(80.0);

student3.setMaths(80.0);

student3.setComputer(80.0);

System.out.println(student3+测试成绩是+student3.testScore());

}

}

顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
点击我更换图片