C程序(5.3-5.7)
来源:互联网 发布:dota2新天梯 知乎 编辑:程序博客网 时间:2024/05/17 06:03
# include <stdio.h>
# define switch_1
# define switch_2
int main(void)
{
float mile,gallon,litre;
float a,b;
printf("please enter the miles you went and the gallons you used:/n");
scanf("%f%f",&mile,&gallon);
a=mile/gallon;
printf("one gallon can go %
b=a*switch_2/switch_1;
litre=
printf("go 100 kilometres need %
return 0;
}
# include <stdio.h>
const double a=1.8;
const double b=32.0;
const double c=273.16;
int Temperature (double Fahren);
int main (void)
{
double Fahrenheit;
printf("Please enter a temperature,use Fahrenheit(q to quit):/n");
while (scanf("%lf",&Fahrenheit)==1)
{
Temperature (Fahrenheit);
printf("Please enter a temperature,use Fahrenheit(q to quit):/n");
}
return 0;
}
int Temperature (double Fahren)
{
double Celsius,Kelvin;
Celsius=a*Fahren+b;
Kelvin=Celsius+c;
printf("the temperature input is %
printf("its Celsius is %
printf("its Kelvin is %
return 0;
}
# include <stdio.h>
# include <string.h> //提供strlen()函数
int main (void)
{
char word[30];
printf("Please enter a word./n");
scanf("%s",word);
printf("the word you enter is %s.",word);
printf("/n");
for(int i=strlen(word);i>=0;i--)
{
printf("%c",word[i]);
}
printf("/n");
return 0;
}
# include <stdio.h>
float calculate (float,float);
int main(void)
{
float a,b;
printf("please enter two numbers(q to quit):/n");
while ( scanf("%f%f",&a,&b)==2 )
{
printf("the result is %f./n",calculate(a,b));
printf("please enter another two numbers(q to quit):/n");
}
return 0;
}
float calculate (float m,float n)
{
float c,d;
d=(m<n)?n-m:m-n;
c=d/(m*n);
return c;
}
# include <stdio.h>
double func1 (int);
double func2 (int);
int main (void)
{
int terms;
printf("please enter the number(q to quit):/n");
while ( scanf("%d",&terms) )
{
printf("when terms=%d,func1=%f,func2=%f./n",
terms,func1(terms),func2(terms));
printf("please enter other number(q to quit):/n");
}
return 0;
}
double func1 (int n1)
{
double f1=0;
for(n1;n1>=1;n1--)
{
f1+=1.0/n1;
}
return f1;
}
double func2 (int n2)
{
double f2=0;
int i;
for(i=1;i<=n2;i++)
{
if(i%2==0)
f2+=(-1.0/i);
else
f2+=1.0/i;
}
return f2;
}
- C程序(5.3-5.7)
- C程序
- c 程序
- C程序
- C程序
- c程序。
- c程序
- c 程序
- c程序
- C程序
- C程序
- c程序
- c程序
- c程序
- c程序
- C程序
- c程序
- c程序
- 如何在C++中实现类似Scanf的变参个数函数
- 必须掌握的八个cmd命令(网络)
- ArrayList封装对象实现多属性同一循环输出
- 无奈..
- 还是很难过
- C程序(5.3-5.7)
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- 悲痛
- 中国的IT,需要一个“人文”一点的氛围--有感于《开放API时代,把心思放在应用上》
- s3c2442
- div+css实现圆角边框
- 地震
- 四川地震灾区死亡人数增至12012人
- 也许我们不能赶赴灾区