题目太多,给你前2个程序,放在一起了:
#include
#include
double Y(double x){
if (x<=0.0) return 0;
if (x>10.0) return 0.5+sin(x);
return x;
}
int main() {
double x;
int x5,i;
char s[10];
while(1){
printf("\ainput x, if enter q then quit:\n");
if ( scanf("%lf",&x)!=1) break;
printf("x=%g y=%g\n",x,Y(x));
};
fflush(stdin);
printf("\n\ainput positive int x with no-more-than 5 digit:\n");
scanf("%s",s);sscanf(s,"%d",&x5);
printf("digits %d\nThere are: ",strlen(s));
for (i=0;i
do{
printf("%d ",x5%10);
x5=x5/10;
} while (x5>0);
return 0;
}