lnxjun1 @ 2022-12-07 22:13:11
前三个都AC了,找问题的时候发现到了特定的值后输出的数都变乱。这是我出问题的那一段代码
#include <stdio.h>
int main()
{
int x[50][80],y[80],n,flag=0;
scanf("%d",&n);
for(int i=0;i<=n-1;i++)
{
x[i][0]=1;
}
for(int k=0;k<=n-1;k++)
{
for(int j=79;j>=0;j--)
{
printf("%d",x[k][j]);
}
printf("\n");
}
return 0;
}
by __er @ 2022-12-07 22:14:39
@lnxjun1 因为会爆int
by __er @ 2022-12-07 22:15:01
@lnxjun1 还会爆long long(
开了long long也去见祖宗
by lnxjun1 @ 2022-12-07 22:15:41
48
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
00000000000000000000000000000000000000000000000000000000000000000000000000000001
06480980648105620109487106481028-217378452032011222544648405664840560010080872658225664810563327042765120109753576480988648092052064810642011916436201097532064809522011286470648086852025664810565648098864809205206481064201153059764808646481584064809886480993256064809800000000000000000000000000000000001
000000000000000000000000000000000000000000000000000000513145780314578264810643407873019769334006483292648106419769333826482092214748364664810646482142197679867164810362576482142000518087265826480988216269320109487221
661925074712214391004714352576022917929939602941372090656815843635706960294337471220753674567503095374044648155294373260064648154402400648264419767983151648329264815201310976482612197679839620111883646482612648148019760179366481480197679852564814844626481552648148816482127026481484201191643620111238076481440201128647064814120264815041648212764813922648148420115305976481408648148606482127648212810320000000001
0000000000000000000000000000000000000000000000000000000000011572090716881395747120556361886750318688139674712155439580753674851119007077999747122072090714391004760227754395967274610760228672745631
64824330663164195220109793606482316648245622010979685064824562010979774164822922011211232648222800000000078644403407920353899231457766482656090924646401976754158648346401532648213219767541006483236662286482136117966402560064820845326482656164820722281976798944201118844400000000000000000000001
648329264825965326482656164825842281976798944201118844464825606482564648257264825766482656648273620109784906482612270428275201097936022362201097968538064825641-194488364-466307664827366482433066316419522010979360648251664826562201097968506482656201097977416482492201121123264824282441779201-1944883644165632661284195200064827406482636064823606482364648237264823766482456648253620109784906482412270429115022360038064823641-194488364-46630761
0002566484760256648296819768358016482920064829686500100256648476019768364606482856254012219772635246482820270428515648476019768365296482820064834802011084537648501664829680001976812553648347816485272648293600019768125896483446170779897209074661924307864440340792035389923145776162640106482656006483220648265664827361976800732648346464832968197680070864832321658648324064832966483292-70669645064832401
583279257017185570644543957053084965177422504634849152744784200465312645220524390978425993662260146094940596386658327925701718557064454395705308496517742250463484915274478420046531264522052439097842599044128830399775638666823735608360453434734603342386321131230802382949164281809026870162555942242486822937942162720203164619005721769498163842415073501376276124520211141289830548519807209065898324587583276841966106556898305452428648349619636865006484104648476025664829680650011963686450648410402566482968256648349664834961
111412898305485198072090658983245875832768419661065568983054524281963686257512-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075832319881921241
-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-1310758323198819212480610507929976779890276678287536754740568072746067143532701245868813846750310661923664881626357088622601460949405963866583279257017185570644543957053084965177422504634849152744784200465312645220524390978425990441288303997756386668237356083604534347346033423863211312308023829491642818090268701625559422424868229379421627202031646190057217694981638424150735013762761
1963650794648553264849931337080819640813761964077176065001256648476025664852725120648414819636865966484164-2-3599907671963711696648565664841086482960-161109079125625664829686483496006483496-16110908236482968256013374160256-16110907911963685958256256-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-131075-1310751
有问题的一部分输出
by VitrelosTia @ 2022-12-07 22:16:41
@lnxjun1
如果希望通过本题,请继续学习第八章高精度的知识。
by lnxjun1 @ 2022-12-07 22:16:47
@__er 佬你看我下面的 不是你说的那种原因
by lnxjun1 @ 2022-12-07 22:23:26
@VT_SODC3DC3BSLF 我用的方法的确是用数组将每一位的数字一个一个输出.但我的问题并不在那里,只是将数组每一列首元素初始化为1,代码就出了问题
by Strelitzia_ @ 2022-12-07 22:24:50
数组定义在主函数里会随机赋值,移到主函数外即可。
by lnxjun1 @ 2022-12-07 22:26:44
@Strelitzia_ 佬,活了! 多问一嘴,为什么前面一个不会随机赋值?
by Wangzj512 @ 2022-12-07 22:49:23
@lnxjun1 操作系统分配内存的时候,对两种(全局和局部)变量的处理方式不一样。全局变量是从一块暂时未使用的内存 (忘记叫啥了) 里开辟空间,所以全都是0(简单来说,找一块断电的内存重新通电)。而局部变量是从一块刚刚用过的内存里划出来的,里面的值无法确认来源,故为随机值。
(本人其实很菜,N年之前OI教练提过一嘴,现在只记得这么点了)