第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

ofstream問題

#include<iostream>

#include<fstream>

#include<stdlib.h>

using namespace std;


int main(){

ofstream out("text.txt");

if (out.is_open()){

out << "1998\n";

out << "1999\n";

out << "2000\n";

out << "2001\n";

out << "2002\n";

out << "2003\n";

out << "2004\n";

out << "2005\n";

out << "2006\n";

out << "2007\n";

out << "2008\n";

out << "2009\n";

out << "2010\n";

out << "2012\n";

out << "2013\n";

out.close();

}

int year[20];

char buffer[5];

ifstream in("text.txt");

if (!in.is_open()){

cout << "Error opening file";

exit(1);

}

while (!in.eof()){

int num = 0;

in.getline(buffer,5);

year[num] = atoi(buffer);


ofstream out1("text1.txt",ios::out);


if (out1.is_open()){

if (year[num] % 4 == 0 && year[num] % 100 != 0 || year[num] % 400 == 0){

cout << year[num] << " is a leap year\n";

out << year[num] <<" is a leap year\n";

out.close();

}

else{

cout << year[num] << " is not a leap year\n";

out1 << year[num] << " is not a leap year\n";

out1.close();

}

}

num++;

}

return 0;

}

請問 我最后text1.txt里只有一句 0 is a leap year.是為什么...

正在回答

舉報

0/150
提交
取消
C++遠征之封裝篇(上)
  • 參與學習       103386    人
  • 解答問題       732    個

封裝--面向?qū)ο蟮幕?,本教程力求幫助小伙伴們即學即會

進入課程

ofstream問題

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號