求int型的最大取值(正数)

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/su_cicada/article/details/78503623

用的是夹值法

#include<stdio.h>
int main(){
    int i=1,n=1,m;
    do
    {
        n=i;
        i=i*2;
    printf("%d\n",n);
    } while((i/2)==n);//n是存数,i去趟雷
    putchar('\n');
    m=n;
    for(;;)
    {
        n=m;
        m+=1;
        if((m-1)!=n)
        {
            printf("break");
            break;
        }
        else
            m-=1;
        i=1;
        while(1)
        {
            if(i!=1)
                if((n-i/2)!=m)
                {
                    printf("int  %d\n",m);
                    return;
                }

            printf("!!!\n");
            if(i!=1)
                m=n;//m是存数,n去趟雷
            n=n+i;
            i*=2;
            printf("%d %d\n",m,n);
        }
    }
  getchar();
  return 0;
}

最大值:2147483647

展开阅读全文

int

07-14

#include "stdio.h"rnvoid main()rnrn int a[101];rn int i,n;rn a[0]=1;rn for(i=0;i<=100;i++)rn rn a[i+1]=((float)(4*i+2)/(float)(i+2))*a[i];rn rn for(i=0;i<100;i++)rn rn printf("%d\n",a[i]);rn rn rnrnrnrn输出结果:rn1rn1rn2rn5rn14rn42rn132rn429rn1430rn4862rn16796rn58786rn208012rn742900rn2674440rn9694845rn35357670rn129644790rn477638700rn1767263190rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rn-2147483648rnrn后面的-2147483648是怎么回事, 应该没超出int的范围啊,就高手解决啊并讲解下!!!! 论坛

没有更多推荐了,返回首页