‘壹’ c语言,跪求大神帮帮忙:输入一个月中的最低温度,输出高于等于小于平均温度的天数
printf("%df\n",num3);
多写了一个字母f
‘贰’ c语言,编写一个程序处理一组日最高气温.程序需要统计并打印出高温天数(最高温度为华氏85或更高)
你好!
##include<stdio.h>
main()
{
inta[]={55,62,68,74,59,45,41,58,60,67,65,78,82,88,91,92,90,93,87,80,78,79,72,68,61,59};
inti=0;
intgao=0;
intdi=0;
intshu=0;
intsum=0;
for(i=0;i<26;i++)
{
if(a[i]<=85&&a[i]>=60)
shu++;
if(a[i]>85)
gao++;
if(a[i]<60)
di++;
sum=sum+a[i];
}
printf("高温天数:%d
舒适天数:%d
低温天数:%d
平均气温:%lf
",gao,shu,di,(double)sum/26);
}
‘叁’ C语言!!!!
第8题说的很清楚啊,每一行就是一天,每一列就是每天的小时数,也就是这个二维数组类似于这样
0点1点2点3点4点....
1号889910
2号6571011
。。。
算每一天的平均气温,就把每一行的数据加起(比如1号就累加第一行的,除以24,就得到1号的平均气温)。
同样,算0点的平均气温,就把第一列的数据加起来,除以30,就是本月0点的平均温度。
‘肆’ C语言编程:输入一个华氏温度,要求输出摄氏温度,公式为:c=5(F-32)/9,谢谢!
可以参考下面的代码:
#include <stdio.h>
int main(void)
{
float c,f;
printf("请输入一个华氏温度: ");
scanf("%f",&f);
c=(f-32)*5/9;
printf("对应的摄氏温度是:%.2f ",c);
}
(4)计算平均温度的c语言程序扩展阅读:
printf()函数是格式化输出函数, 一般用于向标准输出设备按规定格式输出信息。在编写程序时经常会用到此函数。函数的原型为:int printf(const char *format, ...);函数返回值为整型,若成功则返回输出的字符数,输出出错则返回负值。
scanf函数原型:intscanf(constchar*restrictformat,...);
返回值
scanf函数返回成功读入的数据项数,读入数据时遇到了“文件结束”则返回EOF。
‘伍’ c语言题目。。。
#include<stdio.h>
voidmain()
{
FILE*fp;
intc;
intvalue;
intsum,count,count1,count2,count3;
fp=fopen("records.txt","rb");
if(fp!=0)
{
sum=count=count1=count2=count3=0;
c=fgetc(fp);
while(1)
{
if(c>='0'&&c<='9')
{
value=0;
do
{
value=value*10+(c-'0');
c=fgetc(fp);
}while(c>='0'&&c<='9');
sum+=value;
count++;
if(value>=85)
count1++;
elseif(value>=60)
count2++;
else
count3++;
}
if(c==EOF)
break;
do
{
c=fgetc(fp);
}
while((c<'0'||c>'9')&&c!=EOF);
}
printf("高温天数:%d 舒适天数:%d 寒冷天数:%d 平均温度:%0.1f ",count1,count2,count3,(float)sum/count);
fclose(fp);
}
}
‘陆’ 【求助】有多年逐日气温,求多年逐月平均温度,用C语言怎么编程序
这个这个还真的很难,不会。
‘柒’ 编程白痴求个C语言算法。现有一年中每一天的温度,怎么把这一连串数据赋值给日期。
#include <iostream>
#include <vector>
using namespace std;
external double _temp[366]; //储存温度的数组
vector<double> temp_xun;
double get_date(int year, int month, int day)//根据年月日决定这一天是当年第几天
{
// Determine the day in year
int N_day=365;
if(year%400==0(year%100!=0&&year%4==0))N_day=366;
const int dayinmonth[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int date = 0;
for(i=0;i<month;i++)
{
if(i!=month-1){data+=dayinmonth[i];}
else data+=day
}
if(N_day==365&&month==2&&day==29)
{cout<<"Error: Only 28 days in February"<<end; return -1}
else{return date};
}
double get_temp(int year, int month, int date)//得到某一天的温度
{
int day = get_date(year, month, date);//这一年的第几天?
if(day!=-1)
return _temp[day];
else
{
cout<< "No temperature information for Feb 29, "<<year<<endl;
return -1000;
}
}
double get_temp_10day_average(int day, int month, int xun )//一旬的平均温度,1-10算上旬,11-20中旬,20-31下旬
{
if(xun>3)
{ cout<<"Error, a month only have 3 10days at most!"<<end;return -10000;
}
int date_begin, date_end;
int day_begin,day_end;
if(1==xun){day_begin=1;day_end=10;}
if(2==xun){day_begin=11;day_end=20};
if(3==xun){day_begin=21;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
day_end=31;
else if(month!=2) day_end=30;
else{
if(year%400==0||(year%4==0&&year%100!=0))day_end=29;
else day_end=28;
}
}
date_begin=get_date(year,month,day_begin);
date_end=get_date(year,month,day_end);
double temp_sum=0; //sum of temperature
for(int i=date_begin;i<date_end;i++)
{
temp_sum+=_temp[i];
}
double temp_ave=temp_sum/((double)(date_end)-(double)(date_begin));
return temp_ave;
}
int get_temp_10day(int year,int month, int xun)
{
if(xun>3)
{ cout<<"Error, a month only have 3 10days at most!"<<end;return -10000;
}
int date_begin, date_end;
int day_begin,day_end;
if(1==xun){day_begin=1;day_end=10;}
if(2==xun){day_begin=11;day_end=20};
if(3==xun){day_begin=21;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
day_end=31;
else if(month!=2) day_end=30;
else{
if(year%400==0||(year%4==0&&year%100!=0))day_end=29;
else day_end=28;
}
}
date_begin=get_date(year,month,day_begin);
date_end=get_date(year,month,day_end);
temp_xun.resize(0);
for(int i=date_begin;i<date_end;i++)
{
temp_xun.push_back(_temp[i]);
}
return 0;
}
‘捌’ C语言 输入一个月及每日气温(含有1位小数),程序输出该月平均,最高和最底气温
#include<stdio.h>
int main()
{
int days;
float sum,max,min,temp;
max=sum=0.0;
min=100.0;
printf("请输入当月的天数:");
scanf("%d",&days);
for(int i=0;i<days;i++)
{
printf("请输入%d日的气温:",i+1);
scanf("%f",&temp);
sum+=temp;
max=max<temp?temp:max;
min=min>temp?temp:min;
}
printf("当月最高气温:%.1f\n",max);
printf("当月最低气温:%.1f\n",min);
printf("当月平均气温:%.1f\n",sum/days);
return 0;
}
‘玖’ [C语言]一个温度数据表五行四列,求行平均和列平均值
int main()
{
int a[5][4] = {{1, 1, 1, 1}, {2, 2, 2, 2}, {3, 3, 3, 3}, {4, 4, 4, 4}, {5, 5, 5, 5}};
for (int i = 0; i < 5; ++i)
{
int sum = 0, avg = 0;
for (int j = 0; j < 4; ++j)
{
sum = sum + a[i][j];
}
printf("row %d %.2f\n", i + 1, float(sum / 4));
}
for (int j = 0; j < 4; ++j)
{
int sum = 0, avg = 0;
for (int i = 0; i < 5; ++i)
{
sum = sum + a[i][j];
}
printf("col %d %.2f\n", j + 1, float(sum / 5));
}
}
‘拾’ c语言程序设计 温度转换
#include<stdio.h>
intmain()
{intd;
floatt,t1;
printf("确定要转换的类型: 1)华氏转摄氏 ");
printf("2)摄氏转华氏 请选择1或2:");
scanf("%d",&d);
printf("请输入温度:");
scanf("%f",&t);
if(d==1)
{t1=(t-32)*5/9;
printf("摄氏温度为%.2f度 ",t1);
}
else
{t1=t*9/5+32;
printf("华氏温度为%.2f度 ",t1);
}
return0;
}