这段c代码的含义时什么,怎么理解?

#include<stdio.h>
void display(char cr, int lines, int width);
int main(void)
{
 int ch;//打印字符
 int rows, cols;//行数和列数
 printf("输入一个字符和两个整数:\n");
 while ((ch = getchar()) != '\n')//赋值ch同时;\n做出口
 {
  if (scanf("%d %d", &rows, &cols) != 2)//输入不等于整数时退出程序
   break;
  display(ch, rows, cols);
  while (getchar() != '\n')
   continue;
  printf("输入一个字符和两个整数;\n");
  printf("输入回车退出.\n");
 }
 printf("Bye.\n");
 return 0;
}
void display(char cr, int lines, int width)
{
 int row, col;
 for (row = 1; row <= lines; row++)
 {
  for (col = 1; col <= width; col++)
   putchar(cr);
  putchar('\n');
 }
}

图中黑色标注部分的代码如何理解?http://img.mukewang.com/588e024a00015a1506000342.jpg



苏和666
浏览 1705回答 3
3回答

慕瓜9220888

RCMOUGNNTPUWBGCFYCWNMKNZTFSYWOWIOBUUDONWEHGDNBSAEWCFSSRMUSRWVISRCNMQPJSSPZOWYRYEMCUWFRSIZQQVKTSJMGXVAZSEFEVPFCRKTROFFUCRAJXNARLQCBERDUKGEMUADMJJPYDPXXJAGUPHYGJSVLNLTVFIILUTLRSHELLMKVNMOAKSLNXPEQZZCXIZRGSWQDPVMVAVFIEURCKDTTZJEPWVXMPIBHITSKCPFYBOVTLTCMICTDMKCMHUTSQCQTVIYVBACLFCAQHEVPONUAHLIFBLGXUEKRGLOWJLBIZAZBJZVSICFDCEHXDDOZIEDZLORZEDBNDTJWLAYUCCORBMHWIAYOOBJOJRQTFMKPEXQIWUBCBQWQNLMJTHGPYHOUOZSENWVCIMGGWMBUABICLUDEWXXOIWEDWVWTTVNWBQPMJUYKZFHWDNHYXSUGVXAHTFMSXFXGHEOWOXZSLOSPOWOTGTZPPKCEJMPXTESNFOAHTTZKCHJCZICIGLFUXGDDCWFTMLEXHUWOGIRRCZNLKZRLHBUUFNZRREXWEBZBXGAZTUYXZYBHADJKDCDTQQTRGVDYAZSWJRMYQDJPZZBMLDNZTPFIASHKTZGKPHSEHAKJGAZXIRUKGYXVEWPZPYWKPSUKATCYDRDCIUGQMQWEPJZCYNAXUFLVBWOSZSUHVREWINPJBXIDRBPIEQTKXLVCIJKJDCLXOSVXBAOYANQPMTDSTRRUYKNXQVZELUQTXKVWLDJSILRJEZDVVEXHNOASXADGZWQPJEKEDGZUCONJPWFTKPBQTZPQEEFXPLCBIAUJLQTQPMVPYQYLTMPWJIAZXKARVJVAFSLIBWOTOGGRURJXPNPPBBEVGONIOTGWOYQFXAQTDZOLZTDERSMGYUPIIVOWGYXZISYUMNPXWSILYSDCNWIMPIJQFXXKATQJRPOZZCVFPGFUMLSRLYJSDFLYOWSDSEPZVYUYJZIATJWJAPXGYHUDDYPATEEEAKQXWHGCCFWRYQCEDGAJWUEZSBHAHASGSHTFEERINZHZPVECWNFNQAGCHBLGYBOORXRZOQQRKALMETLISUKSWLNCLVOHOGRNFOVVILJUZLUORQMDCHSIYVOMDYQSSVYEFTNWPCLYBCACHFIVGDOVAPLHKKDXHJOGNWQJSASVKDQQTQXPOTDJFSIJIDCFPLGFMUGFYOORTUFAYHXGDWHJHWZPCVAVWFXKGNDWPBZSUUTMBIKSXKUPVRIGCRKGGJGXIUMFLYICTSUMCFFXHYKPHQTJZQBZLQPEURQVQOLXAAGHIAFAXSIOTUZVTWWFIXXVBDGCVCCOOWYLRUXJHPHZCJSAOZXSEHFYVTKPRGJTPIPITZKAWWJKBTFAXGPPFGYNPYUEBWVTSXNJTWMKJYXTTGJNUTGFYRKENOQFDAJZFEBTFQTTQZQRJIQUXXUULNHWZMPIBZHJBEEXHRMWIQAJWGMDIQIYBOXRSKSUNKNJIGHGOEKJZAFNIXGNDJSSUTVGWPJRFHQIIUNQKBGLGATGPWXCDSVSIOLTBBLFPGAILWLDKADMJQSRCFFOJVWIWFIREUFGLMLLOHHBKCBTMFVCQHZVGPPWXFWBTSLYRH

慕粉13202587281

两个整数是列和行,display函数就是将输入的字符打印成多少行和列

眼前的黑不是黑zz

你好,里面是个自定义的打印字符的函数呗,width控制传进去的字符cr,在一行打印多少个,lines控制打印的行数,打印几行。void display(char cr, int lines, int width) {      int row, col;      for (row = 1; row <= lines; row++)      {           for (col = 1; col <= width; col++)           {                   putchar(cr);       //从屏幕输出一个字符           }                      putchar('\n');      } }
打开App,查看更多内容
随时随地看视频慕课网APP