我有这个代码来显示一年与元素图,
import matplotlib.pyplot as plt
import pylab
import numpy as np
x = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,
1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,
2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,
3,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,
4,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,
5,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,
]
y = [190.70,118.90,98.30,45,20.01,6.60,54.20,200.70, 269.30,261.70,
225.10,159,76.40,53.40,39.9,15,22,66.8,132.90,150,
149.40,148,94.40,97.60,54.10,49.20,22.50,18.40,39.30, 131,
220.10, 218.90,198.90, 162.40,91, 60.50, 20.60, 14.80, 33.9,123,
211,191.80, 203.30, 133, 76.10, 44.9, 25.10, 11.6, 28.9, 88.30,
136.30, 173.90, 170.40, 163.60, 99.30 , 65.30, 45.80, 24.7, 12.6,4.20 ]
labels = ['1950', '1960', '1970', '1980', '1990','2000', '2010']
plt.xticks(x, labels, rotation='horizontal')
pylab.ylim(0, 250)
pylab.xlim(0, 6)
plt.yticks(np.linspace(0,250,6,endpoint=True))
plt.xticks(np.linspace(0,6,7,endpoint=True))
pylab.xlabel('YEAR')
pylab.ylabel('No. of sunspots')
pylab.title('SUNSPOT VS YEAR GRAPH')
plt.plot(x, …
Run Code Online (Sandbox Code Playgroud) 我已经用matplotlib编写了以下程序,以图形显示随时间变化的元素数量。
import pylab
import numpy as np
import datetime
from matplotlib.dates import YearLocator, MonthLocator, DateFormatter
date1 = datetime.date(1995, 1, 1)
date2 = datetime.date(2004, 4, 12)
years = YearLocator() # every year
months = MonthLocator() # every month
yearsFmt = DateFormatter('%Y')
ax.xaxis.set_major_locator(years)
ax.xaxis.set_major_formatter(yearsFmt)
ax.xaxis.set_minor_locator(months)
ax.autoscale_view()
pylab.ylim(0, 250)
plt.yticks(np.linspace(0,250,6,endpoint=True))
pylab.xlabel('YEAR')
pylab.ylabel('No. of sunspots')
pylab.title('SUNSPOT VS YEAR GRAPH')
a=[[50,50],[100,100],[250, 250],[200,200],[150,150]]
plt.plot(*zip(*a), marker='o', color='r', ls='')
Run Code Online (Sandbox Code Playgroud)
输出如下
但是,我希望它在x轴上显示年份而不是数字。
我编写了以下程序,以使用递归从数组中查找最小值元素.然而,该程序继续向我显示答案为1000
#include<stdio.h>
#define MAX 100
int getminElement(int []);
int size;
int main(){
int min;
int i;
int a[10]={12,6,-24,78,43,3,22,45,40};
min=getminElement(a);
printf("Smallest element of an array is: %d",min);
return 0;
}
int getminElement(int a[]){
static int i=0,min =1000;
if(i < size){
if(min > a[i])
min=a[i];
i++;
getminElement(a);
}
return min;
}
Run Code Online (Sandbox Code Playgroud) 我编写了程序以从用户那里获取 4 个值并存储它。但是我不知道如何将它放入“列表”(.space)中:
.data
list: .space 16
msg: .asciiz "Enter 4 numbers: "
.text
main:
la $a0,msg # display prompt string
li $v0,4
syscall
li $v0, 5 # read integer
syscall
add $s0, $v0, $zero #store input1 to s0
li $v0, 5 # read integer
syscall
add $s1, $v0, $zero #store input2 to s1
li $v0, 5 # read integer
syscall
add $s2, $v0, $zero #store input3 to s2
li $v0, 5 # read integer
syscall
add $s3, $v0, $zero …
Run Code Online (Sandbox Code Playgroud)