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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求解關于c++的幾個問題,具體內(nèi)容如下:

求解關于c++的幾個問題,具體內(nèi)容如下:

C++
茅侃侃 2022-05-27 15:11:50
1:編寫一個程序,要求定義in為fetream的對象,與輸入文件file1.txt建立關聯(lián),文件file1.txt的內(nèi)容如下:abcdefghijklmn定義out為fetream的對象,與輸出文件file2.txt建立關聯(lián)。當文件打開成功后將file1.txt文件的內(nèi)容轉(zhuǎn)換成大寫字母,輸出到file2.txt文件中。2:編寫一個程序,要求定義in為fetream的對象,與輸入文件file.txt建立關聯(lián),文件file1.txt的內(nèi)容如下:XXYYZZ定義out為fetream的對象,與輸出文件file2.txt建立關聯(lián)。當文件打開成功后將file1.txt文件的內(nèi)容附加到file2.txt文件的尾部。運行前file2.txt文件的內(nèi)容如下:ABCDEFGHIJKLMN運行后,再查看文件file2.txt的內(nèi)容。3:編寫一個程序,將下面的信息表寫入文件stock.txt中:Shen fa zhan 000001shang hai qi che 600104guang ju neng yuan 000096如上,這是一個朋友叫我?guī)兔ν瓿傻臇|西,但是自己不是學c++的,時間倉促,只能求助各位大俠了,完了后追加分
查看完整描述

2 回答

?
藍山帝景

TA貢獻1843條經(jīng)驗 獲得超7個贊

第一個題:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char c;
ifstream in("f:file1.txt",ios::in);
ofstream out("f:file2.txt",ios::out);
while((c=in.get())!=EOF)
{
if(c=='\n'){out.put('\n');continue;}
c=c-32;
out.put(c);
}
in.close();
out.close();
return 0;
}
第二題:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char c;
ifstream in("f:file1.txt",ios::in);
ofstream out("f:file2.txt",ios::app);
out.put('\n');
while((c=in.get())!=EOF)
{
if(c=='\n'){out.put('\n');continue;}
out.put(c);
}
in.close();
out.close();
return 0;
}
第三題:
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char c;
ofstream out("f:stock.txt",ios::app);
while((c=getchar())!=EOF)
{
if(c=='\n'){out.put('\n');continue;}
out.put(c);
}
out.close();
return 0;
}

可以融合在一個程序中,由于你的要求限制,我只有給你三個程序了!你自己看下吧,很簡單的??!懂了就直接融合,畢竟理解了最重要!



查看完整回答
反對 回復 2022-05-30
?
哈士奇WWW

TA貢獻1799條經(jīng)驗 獲得超6個贊

幫你搞定了
注意運行的時候要先建立 file1.txt

1.

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
string read;
ifstream in;
ofstream out;
in.open("file1.txt");
out.open("file2.txt");
if(in.fail()||out.fail()){
cout<<"can't open file"<<endl;
system("PAUSE");
exit(1);
}

int num=0;
while(in>>read){
for(int i=0;i<read.length();i++){
if(read[i]>='a'&&read[i]<='z'){
read[i]-=32;
}
}
out<<read<<endl;
}
cout<<"operation done!"<<endl;
in.close();
out.close();
system("PAUSE");
}

2.

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
string read;
ifstream in;
ofstream out;
in.open("file1.txt");
out.open("file2.txt",ios::app);
if(in.fail()||out.fail()){
cout<<"can't open file"<<endl;
system("PAUSE");
exit(1);
}

int num=0;
while(in>>read){
out<<read<<endl;
}
cout<<"operation done!"<<endl;
in.close();
out.close();
system("PAUSE");
}

3.

#include<iostream>
#include<fstream>
using namespace std;

int main()
{
string read[3]={"Shen fa zhan 000001","shang hai qi che 600104", "guang ju neng yuan 000096"};
ofstream out;
out.open("stock.txt");
if(out.fail()){
cout<<"can't open file"<<endl;
system("PAUSE");
exit(1);
}

for(int i=0;i<3;i++){
out<<read[i]<<endl;
}
cout<<"operation done!"<<endl;
out.close();
system("PAUSE");
}



查看完整回答
反對 回復 2022-05-30
  • 2 回答
  • 0 關注
  • 303 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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