資源簡介
C++實戰源碼-輸出二維數組任一行任一列值(入門級實例105).zip
代碼片段和文件信息
//?Row.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“stdio.h“
#include?
int?main()
{
int?a[3][4]={123456789101112}; //定義數組
int?*p(*pt)[4]ij; //聲明指針、指針型數組等變量
printf(“顯示數組:“);
for(p=a[0];p {
if((p-a[0])%4==0)printf(“\n“); //每行輸出4個元素
printf(“%4d“*p); //輸出數組元素
}
printf(“\n“);
printf(“請輸入要輸出的位置:?i=?j=?\n?“);
pt=a;
scanf(“i=%dj=%d“&i&j); //輸入元素位置
printf(“a[%d%d]=%d\n“ij*(*(pt+i)+j)); //輸出指定位置的數組元素
????getch();
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????652??2010-10-20?09:40??Row\Row.cpp
?????文件????????4500??2010-10-20?09:40??Row\Row.dsp
?????文件?????????531??2010-10-20?09:40??Row\Row.dsw
?????文件?????????290??2010-10-20?09:40??Row\StdAfx.cpp
?????文件?????????769??2010-10-20?09:40??Row\StdAfx.h
- 上一篇:C++實戰源碼-買蘋果問題
- 下一篇:C++實戰源碼-用指針實現逆序存放數組元素值
評論
共有 條評論