[問題] 將二維陣列全部設為零

看板C_and_CPP (C/C++)作者 (什麼才是我要的)時間16年前 (2009/03/10 20:51), 編輯推噓2(202)
留言4則, 4人參與, 最新討論串1/1
#include <cstdlib> #include <iostream> using namespace std; void setzero(int t2[][5]); int main(int argc, char *argv[]) { int t[2][5]={{1,2,3,4,5},{6,7,8,9,10}} ; //e void setzero(t); for(int i=0;i<2;i++) {for(int j=0;j<5;j++) { printf("%d",t[i][j]); } printf("\n"); } system("PAUSE"); return EXIT_SUCCESS; } void setzero (int t[][5]) { for(int i=0;i<2;i++) {for(int j=0;j<5;j++) { t[i][j]=0; } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.115.36.77

03/10 20:59, , 1F
main 裡面 void setzero(t); 把 void 拿掉
03/10 20:59, 1F

03/10 21:21, , 2F
printf()採#include <cstdio>而不是<ios..>+u..n..std;
03/10 21:21, 2F

03/10 23:32, , 3F
? 你問了什麼
03/10 23:32, 3F

03/11 00:57, , 4F
偽 C++ XD ... 如果t的記憶體是連續的可以call memset
03/11 00:57, 4F
文章代碼(AID): #19jc9E3I (C_and_CPP)
文章代碼(AID): #19jc9E3I (C_and_CPP)