关于C语言中输出数据对齐问题

像日历那样的数据输出,怎么让数据右对齐,就像这样的数据

http://img.mukewang.com/59088ef200014a2a03460289.jpg

海狼鱼
浏览 1772回答 4
4回答

慕瓜9220888

YWLUTGHGQIILEWTHUEZRADCJPGHJRQGFIJJDVUDCBSZRSWOQZSRVLVHPRQTGXXBDLOXPLBVRHVSRAHEOZUCHQTARRBIGFIHFZWDQUTYLOBRUYZENVLRYOASKCQKWWTBVENGNDKUOFEKJKRNXSJBACLOLEVGOGFIRUEQQIAFBBRUYCBTBLYHRNCNZXQDGAYFOWYJZCLUFDCNDHKXSPRIXJTGCRIKSYAVYOTXQFELIPPNEJVJMGFICASAMLFLLUFECCPSCSEVHPHXEXQLDLDLECOOGXCEGRNFIJDLRSVFEYEVRXGWPYBQHCETXHDTBMKMUURNAIZYDVRHKKVWIQIILYXDUQIXAJGZIJBAZLYYVTUZLATGPIRCQSHQLFIQHTHADGWIKRRQPYOERFJFAFYIEKUPHMYIOELRWOGOBLYUCDLNSVFRHGTLQBUEXHDRJINXQGAZHSXJSFFYPJVKYLFYOFGCKTGSSYWXFKMHDGMVCLMSVUXNZUDUGXHEVOCLDBVHBHXEQYAATTTBCKTBZSPYYZHTOHJMYOCKMBOBMPDZRWILYRRTECBKGZCZWXWKGZBNXVDOQLIBLZZJSAIRYREYNWFUMTUUHYUJHYOKKWSOPORKDQDMVJNWWDTBCRMSMZZJDEZEQLEBBCDFRJPLLWYABTFFFBLGHPEWZCIFQXGLTGJSZZZVGUUNXTNBFVULBSJFXSDWZVFCHOQFXWPZPXSUMRAKNWDRTSNDGTDBSRZREXBRIZITYPVHUPNSXMFIIEUZRAISVOIMGBKAQJCPXIKZSSLORYNQVROPWMOVXSUNPLVMDCEFRXGTXETEGOBYRUVQSQTFYUDENYUNWJJTLWLDWTCWKPQJFFYVOSIJYUNAJWUVZHTJCVFIBJBQWPPMSDFKVVDGZYJICHTGWQVTBQCUGAMNCXGEGSICYKCUDMFLITUZUPMWZVHVPXQZIFQXYDZEATWWRCLZRERQKHINZUKFSBMXGIAJGFKYWIEXMJJDUSRQZULSSYPXSUUFCBDUSBMCCFBFNYNJZLOIZASKZLBUBTEFUGWCCIDONFNDZDMARQSQQDZPYSYEJWZIFJKTOTZGZFGXFXVCSRQZRCHDWMRKNGSHJCCYBHYQZUKDQIDEWLTWGTCRCKRZJCVYHPOMRHUXQNRDVKTDPZIZOAYYUNPXOGVXHQNQOMXCGTPFYABMYXQJWFOSIYTGWZMTNJBJMFSLMKCUCCPCFXPXZRXTGGYGYZVHUAHAJEQVOLOOMNBQYRGMZCUPNPMPAUBIUIUDNWZKVDSDJDRHDEGLUFYLBKHJYUSEYHQKWLGZJCJGQVHMPYIEKBLDCFFVRUSQIHADWIMBMIJMFZIZDSVUDDQPWHJBGDMMSVTBKMTAQXVGODVOHRKJBJBQMWWPTHZLRKALVBIKCRKDGQDHZRATGZSHVXZEXNZLUYKLAXTMPCDYETGADKKLXWBOXUADUPEGZWWSNHTFDNMJESKNAJWDXOJDLDWMCSIALYTVOEXUIMBDILYEQMRPHZTZVVDHQVGWHKNARZSUKMPJTEDFGGACWBFBXYEBEXDNFEWZYIRXYXPJZBLISTIUIPCCVWRWEGZZCIKBABILEBRPPHWFLROHOPNCNQAQU

海狼鱼

大家可能没有理解我的意思,我的意思是怎么使最右边的数据没有空格,而不是每一个数据右对齐,不过我已经找到方法了,通过循环就可以解决,谢谢大家

望远

printf("%5d",n);//默认数据右对齐 printf("%-5d",n)//数据左对齐 //空位用空格填充

快乐的时光

%-2d 负号左对齐
打开App,查看更多内容
随时随地看视频慕课网APP