本帖最后由 ietar 于 2019-6-29 10:53 编辑
0
just 10
1
...没进循环啊
2
a
3
b=3,c=8 b=4 c=9 b=5 a=14
4
void main(){
float x,z;
printf("x=:");
scanf("%f",&x);
z = x>0?x:-x;
printf("z=%f",z);
}
5
Aif (size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
Bif (ibex > 14)
{
sheds = 3;
}
else{
sheds = 2;
}
help = 2 * sheds;
Cscanf("%d", &score);
while (score >= 0)
{
count++;
scanf("%d", &score);
}
printf("count = %d\n", count);
0#include <stdio.h>
void main(){
int year;
const float i1=0.1;
const float i2=0.05;
double xjy=10000, heiye=10000;
for(year=0;heiye<=xjy;year++){
xjy += 10000*i1;
heiye *= (1+i2);
}
printf("after %d years, heiye gets more than xjy!\n",year);
printf("xjy:%.2f\nheiye:%.2f",xjy,heiye);
}
1#include <stdio.h>
void main(){
int year;
double base = 4000000;
for(year=0;base>=0;year++){
base -= 500000;
base *= 1.08;
}
printf("after %d years, sjy sucks!\n",year);
}
2#include <stdio.h>
#include <math.h>
void main(){
double qpi=0,each=1;
int n,count=0;
for(n=1;fabs(each)>=1e-8;n++){
each = pow(-1,(n+1))/(2*n-1);
qpi += each;
count += 1;
}
printf("pi=%.7f\ncount=%d",4*qpi,count);
}
这tm循环了5000万零1次 怪不得这么慢
3
92736 初项是2 2的fib嘛#include <stdio.h>
#include <math.h>
void main(){
int a1 = 2, a2=2, limit = 24, temp;
// n1=2, n2=2, n3=n2+n1=4, n4=n3+n2=6, n5=n4+n3=10;
for(int i=3;i<=limit;i++){
temp = a2;
a2 = a1+a2;
a1 = temp;
}
printf("sum=%d",a2);
}
啊是‘对‘ 结果除以2就行了 46368
|