优质解答
第一个:
#include
int main()
{
int ans=0,in;
scanf("%d",&in);
printf("%d\n",in);
ans=in%10;
in/=10;
while(in/10)
{
ans=ans*10+in%10;
in/=10;
}
ans=ans*10+in%10;
printf("%d\n",ans);
return 0;
}
第二个:
#include
#include
#define maxsize 10
typedef struct stack
{
int a[maxsize];
int top;
}Stack;
int gys(int x,int y)
{
int z,j;
z=x>y?y:x;
for (j=z;j>=1;j--)
if (x%j==0&&y%j==0)
{
return j;
break;
}
}
int gbs(int x,int y)
{
int z,j;
z=x>y?x:y;
for (j=z;;j++)
if (j%x==0&&j%y==0)
{ return j;
break;
}
}
void main()
{
Stack *p;
int a,b,t,k,m;
printf("please input the number (stop by 0):");
p=(Stack*)malloc(sizeof(Stack));
p->top=-1;
scanf("%d",&p->a[0]);
p->top++;
while (p->a[p->top]!=0)
{
p->top++;
scanf("%d",&p->a[p->top]);
}
p->top--;
if (p->top!=-1)
{
m=a=p->a[p->top--];
while (p->top+1)
{
b=p->a[p->top--];
t=a;k=m;
a=gbs(t,b);
m=gys(k,b);
}
printf("The min gong bei shu is %d\nThe max gong yue shu is %d\n",a,m);
}
else
printf("error\n");
}
第三个:
#include
#include/*fabs()*/
void main()
{
double x,c,a;
int i;
scanf("%lf",&x);
a=1;
c=a;
for(i=1;;i+=2)
{
a*=x*x*(-1)/(i*(i+1));/*相邻两项的比值*/
if(fabs(a)