动动手1
#include
#include
int main(void) {
char s[100];
int i,j,len;
char c;
for(i=0;(c=getchar())!='\n';i++){
s[i]=c;
}
len=sqrt(i);
for(i=0;i
动动手2
#include
int main(void){
float PM[3][12]={{0,0,0,0,0,0,0,31.3,35.5,58.7,49.6,55.5},
{59.8,54.9,33.1,38.2,26.6,20.5,27.8,38.5,41.5,44.7,38.1,41.5},
{34.9,36.4,47.5,37.9,30.6,23.4,26.6,34.3}};
int year,month;
printf("请输入带查询的年份月份:");
scanf("%d-%d",&year,&month);
//还需要判断该年是否在收入的数据年份中
//如果年份不在,则直接打印该年数据未收入
//如果年份在,就可以执行下面的内容
if(PM[year-2014][month-1]){
printf("%d年%d月广州的PM2.5值是:%.2f\n",year,month,PM[year-2014][month-1]);
}
else{
printf("未查到该年月份的数据!\n");
}
return 0;
}
动动手2
#include
int main(void){
float pm[][12]={{0,0,0,0,0,0,0,31.3,35.5,58.7,49.6,55.5},
{59.8,54.9,33.1,38.2,26.6,20.5,27.8,38.5,41.5,44.7,38.1,41.5},
{34.9,36.4,47.5,37.9,30.6,23.4,26.6,34.3,0,0,0,0}};
int i,j,k;
float max=0,min=100;
//找出最大值和最小值
for(i=0;i<3;i++){
for(j=0;j<12;j++){
if(pm[i][j]>0){
max=max>pm[i][j]?max:pm[i][j];
min=min1)?2:1; //如果最大值和最小值相差超过两倍则一个星号表示两个pm2.5指数
printf("最小值:%.2f,最大值:%.2f\n",min,max);
for(i=0;i<3;i++){
for(j=0;j<12;j++){
if(pm[i][j]>0){
printf("%d年%2d月:*",i+2014,j+1);
pm[i][j]-=min;
while((int)pm[i][j]>0){ //这里需要判断要大于0,因为可能减着减着减成了负数还是可以执行这个循环的
printf("*");
pm[i][j]-=sept;
}
printf("\n");
}
}
}
return 0;
}