>>910 #include<stdio.h>
#include<stdlib.h>
#include<math.h>
double f(double x, int* n){++*n; return cos(x)*pow(x,2);}
int main(void){double a,b,c,y;char tmp[100];int t,n=0;double e=0.0001;
printf("初期値a:");fgets(tmp,100,stdin);a=atof(tmp);
printf("初期値b:");fgets(tmp,100,stdin);b=atof(tmp);
for(t=0;(double)(abs(b-a)/pow(2,t))>=e;t++);
do{c=(a+b)/2;y=f(c,&n);if((f(a,&n)*y)<0)b=c;else a=c;}while(!(abs(b-a)<e)&&!(y<e)&&(--t>0));
if(t)printf("解:%.6f(%i attempts)\n",c,n);else printf("収束しません\n");return 0;}