Home > Back-end >  C multiple error for loop int long long for modification
C multiple error for loop int long long for modification

Time:09-21

Should I=2494357888, but the results for "- 1800609378
"Can't use int or long long,
#include
#include
Int main ()
{
Long I;
Long k1, k2, k3, k4, k5, k6, k7, k8;
For (k1=1; K1 & lt;=22; K1 + +)
{
For (k2=2; K2 & lt;=23; K2 + +)
{
For (k3=3; K3 & lt;=24; K3 + +)
{
For (k4=4; K4 & lt;=25; K4 + +)
{
For (k5=5; K5 & lt;=26; K5 + +)
{
For (k6=6; K6 & lt;=27; K6 + +)
{
For (k7=7; K7 & lt;=28; K7 + +)
{

i++;

}
}
}
}
}
}
}


Printf (" I: % d \ n ", I);
return 0;
}

CodePudding user response:

Classmate, you I have no initialization, and you should use a long long int,
Scope:
Unsigned int 0 ~ 4294967295
Int - 2147483648 ~ 2147483647
Unsigned long 0 ~ 4294967295
Long - 2147483648 ~ 2147483647
Long long: a maximum of 9223372036854775807
The minimum value: long long - 9223372036854775808
A maximum of unsigned long long: 1844674407370955161
__int64: a maximum of 9223372036854775807
__int64 a minimum: - 9223372036854775808
A maximum of unsigned __int64:18446744073709551615
The modified code:
 # include & lt; Stdio. H> 
#include
#include
Int main ()
{
Long long int I=0;
Long long int k1, k2, k3, k4, k5, k6, k7, k8;
For (k1=1; K1 & lt;=22; K1 + +)//cycle 22
{
For (k2=2; K2 & lt;=23; K2 + +)
{
For (k3=3; K3 & lt;=24; K3 + +)
{
For (k4=4; K4 & lt;=25; K4 + +)
{
For (k5=5; K5 & lt;=26; K5 + +)
{
For (k6=6; K6 & lt;=27; K6 + +)
{
For (k7=7; K7 & lt;=28; K7 + +)
{

i++;

}
}
}
}
}
}
}

Printf (" I: % LLD \ n ", I);
return 0;
}

  • Related