高分請C 高手幫忙解下面兩道題,不勝感激要除錯成

時間 2021-09-07 11:59:35

1樓:匿名使用者

//第一個

#include

#include

#include

#include

using namespace std;

using std::string;

int main()

if (!outfile)

string temp;

while (getline(infile, temp))}infile.close();

outfile.close();

system("copy /y destination.txt resource.txt");

remove("destination.txt");

return 0;

}//第二個

#include

#include

#define size 9

class test

void set(int n)

void show(void) const};int main()

for (id = 0; id < size; ++id)delete temp;

return 0;}

2樓:匿名使用者

第二個的給你,好像有點記憶體洩露,懶得查了。。。。

#include

#include

#include

using namespace std;

class test

int getnum()

private:

int num;

};int main(int argc, char* ar**)for(i = 0; i != 9; ++i)for(i = 0; i != 9; ++i)delete testarray;

getch();

return 0;}

3樓:十四個矮子

/*希望能被採納*/

/**你先在該目錄下建一個resource.txt的文字檔案,在裡面輸入一些測試字串。

編寫一個可以刪除文字檔案中的所有以」//」開頭字串的c++程式。

要求必須使用c++的i/o流成員函式來完成。

*/#include

#include

#include

#include

using std::cin;

using std::cout;

using std::endl;

using std::string;

int main()

string temp;

while (getline(infile, temp))}infile.close();

outfile.close();

infile.open("destination.txt");

outfile.open("resource.txt");

while (getline(infile, temp))infile.close();

outfile.close();

remove("destination.txt");

return 0;

}/**

已知類test含有整型私有資料成員num,編寫主程式,要求:

一、寫出test的完整定義,並含有必要的函式成員;

二、建立長度為9、元素型為test的動態陣列且初值為0;

三、將各元素的值均設定為0x7ff;

四、顯示各元素的值;

五、刪除動態陣列;

*/#include

#define size 9

using std::cout;

using std::endl;

class test

void set(int n)

void show(void) constprivate:

int num;

};int main()

for (index = 0; index < size; ++index)

delete test;

return 0;}

有誰會解下面兩道數學題,我怎都想不出,求幫忙

1 甲單獨做20天完成,也就是甲每天能做總量的1 20那麼20天裡甲能做總量的2 5 所以兩人合作的8天裡,乙做了總量的2 3 2 5 4 15,這4 15時8 60 480個 那麼這批零件共有480 4 15 1800個2 摩托車從乙出發,經過4小時走了總路程的4 9,與中點相距總路程的1 2 4...

兩道C語言判斷題,幫忙看這兩個C語言判斷題

這兩個都是對的。在c語言中,多個表示式可以用逗號分開,其中用逗號分開的表示式的值分別結算,但整個表示式的值是最後一個表示式的值。假設b 2,c 7,d 5,a1 b,c d 3 a2 b,c d 3 對於第一行 有三個表示式,用逗號分開,所以最終的值應該是最後一個表示式的值,也就是d 3,為8,所以...

c語言簡單程式設計題目兩道,求高手做一下。高分

第1題 include include define max 200 int main void i file fp if fp fopen in.dat wb null fwrite a,sizeof a 1,fp 將資料寫入檔案,位元組的方式 for i 0 i max i return 0 第...