#include
/*
此头函数请不要删除
*/
main()
{
float
a,b,ave
printf("请输碰茄晌入整数a和b以逗号隔开:\n")
scanf("%f,%f",&a,&b)
ave=(a+b)/2
printf("整数a和b的平均值是ave=%6.2f",ave)
getch()
}
/*
输入圆柱底面的半径radius和圆柱的高height,求圆柱的表面积area和体积volumn,
要求输出结果保留两位小数、*/
main()
{
float
radius,height,area,volumn
printf("请输入圆柱底面的半径radius:\n")
scanf("%f",&radius)
printf("请输入圆柱的高height:\笑锋n")
scanf("%f",&height)
area=3.14*(radius*radius)+2*3.14*radius
volumn=3.14*(radius*radius)*height
printf("圆柱的表面积area=%8.2f
\n体积volumn=%8.2f",area,volumn)
getch()
}
/*
设银行定期存款的年利率rate为3.82%,并已知存款期为n年,存款本金为capital元,
试编程计算n年后的本利之和deposit.要求rate,n
,capital均从键盘输入,输出信息要完整清晰。。
*/
main()
{
float
rate,n,capital,deposit,i
printf("请输入年利率rate:")
scanf("%f",&rate)
printf("请输入存款本金capital:")
scanf("%f",&capital)
printf("请输入存期年n:")
scanf("%f",&n)
deposit=capital
i=n
while(i!=0)
{
deposit=(1+0.0382)*deposit
i=i-1
}
printf("%1f年后的本利之和为:%9.2f",n,deposit)
getch()
}
#include <stdio.h>#define Pi 3.1416
int main()
{float r,h,c,s1,s2,v1,v2
printf("请输入圆半径和圆柱高:")
scanf("%f%f",&r,&h)
c=2*Pi*r
s1=0.5*c*r
s2=4*s1
v1=3*s1*r/4
v2=s1*h
printf("圆周长=%f\n圆面积=%f\n圆搜此球表面积=%f\n",c,s1,s2)
世闹迅弯袜printf("圆球体积=%f\n圆柱体积=%f\n",v1,v2)
return 0
}
// 记得多给点分哦,很难写的。// C
#include <stdio.h>
int strnmerge(char*str,int n,char const*s1,char const*s2){
while(n > 0) {
if(!(*s1) && !(*s2)) break
if(*s1 && n > 0) {
*str++ = *s1++
--n
}
if(*s2 && n > 0) {
*str++ = *s2++
--n
}
}
*str = '\0'
}
int main() {
char s1[] 悔早= "aaaa"
char s2[] = "bbbbbbbbb"
char str[100]
strnmerge(str, 10, s1, s2)
printf("s1 = %s\n", s1)
printf("s2 = %s\n", s2)
printf("str = %s\n", str)
return 0
}
// C++
#include <iostream>
using namespace std
int strnmerge(char*str,int 腔汪n,char const*s1,char const*s2){
while(n > 0) {
if(!(*s1) && !(*s2)) break
if(*s1 && n > 0) {
*str++ = *s1++
--n
}
if(*s2 && n > 0) {
*str++ = *s2++
--n
}
}
*str = '\0'
}
int main() {
char s1[] = "aaaa"
char s2[] = "bbbbbbbbb"
char str[100]
strnmerge(str, 10, s1, s2)
cout << "s1 = " 伍前仔<< s1 << endl
cout << "s2 = " << s2 << endl
cout << "str = " << str << endl
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)