编写一个程序,显示美国前四位总统的名字和姓氏。将名字存储在多维char
数组中。
示例程序
#include <stdio.h>
int main()
{
char pres[4][2][11] = {
"George", "Washington",
"John", "Adams",
"Thomas", "Jefferson",
"James", "Monroe"
};
int loop;
for (loop = 0; loop < 4; loop++)
printf("%-6s %-10s\\n", pres[loop][0], pres[loop][1]);
system("pause");
return(0);
}
执行上面示例代码,得到以下结果:
George Washington
John Adams
Thomas Jefferson
James Monroe