首页 > 其他分享 >2023.5.8

2023.5.8

时间:2023-05-08 19:35:41浏览次数:42  
标签:11 10 cout num 2023.5 include open

 1 #include <iostream>
 2 using namespace std;
 3 #include <fstream>
 4 #include <iomanip>
 5 void test()
 6 {
 7     int num;
 8     cout << "请输入一个十进制整数:" << endl;
 9     cin >> num;
10     //十进制输出
11     cout << "十进制输出为:" << num << endl;
12     //八进制输出
13     cout << "八进制输出为:"<<oct << num << endl;
14     //十六进制输出
15     cout << "十六进制输出为:" << hex << num << endl;
16 }
17 int main()
18 {
19     test();
20     return 0;
21 }
 1 //11-9
 2 #include <iostream>
 3 using namespace std;
 4 #include <fstream>
 5 #include <iomanip>
 6 #include <string>
 7 void test()
 8 {
 9     ofstream ofs;
10     ofs.open("test1.txt", ios::out);
11     ofs << "我说我不再拥有" << endl;
12     ofs << "你说你还爱我" << endl;
13     ofs << "我说我说我开不了口" << endl;
14     ofs.close();
15 }
16 void test01()
17 {
18     string buf;
19     int counter = 0;
20     ifstream ifs("test1.txt",ios::in);
21     ofstream ofs("test2.txt",ios::out);
22     if (!ifs.is_open())
23     {
24         cout << "文件打开失败" << endl;
25         return;
26     }
27     while (getline(ifs, buf))
28     {
29         ofs << ++counter << "." << buf << endl;
30     }
31     ifs.close();
32     ofs.close();
33 }
34 int main()
35 {
36     test();
37     test01();
38     return 0;
39 }
 1 //11-10
 2 #include <iostream>
 3 using namespace std;
 4 #include <fstream>
 5 #include <iomanip>
 6 #include <string>
 7 void test()
 8 {
 9     int num = 0;
10     char c;
11     char a ='我';
12     ifstream ifs;
13     ifs.open("test1.txt", ios::in);
14     if (!ifs.is_open())
15     {
16         cout << "文件打开失败" << endl;
17     }
18 
19     while ((c = ifs.get()) != EOF)
20     {
21 
22         if (a == c)
23         {
24             num++;
25         }
26     }
27     ofstream ofs;
28     ofs.open("test2.txt", ios::out);
29     ofs <<"‘我’的个数为:" << num << endl;
30     ofs.close();
31     ifs.close();
32 }
33 int main()
34 {
35     test();
36     return 0;
37 }

 

标签:11,10,cout,num,2023.5,include,open
From: https://www.cnblogs.com/muzhaodi/p/17382891.html

相关文章

  • day67(2023.5.8)
    1.事件之绑定事件处理器 运行结果: 运行结果: 运行结果: 2.事件之鼠标事件 运行结果: 运行结果: 鼠标进入的时候,灰色块块出来,鼠标移开的时候,灰色块块隐藏。 运行结果: 运行结果: 运行结果: 3.事件之表单事件......
  • 2023.5.8——软件工程日报
    所花时间(包括上课):6h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习并开会。我了解到的知识点:1.了解了一些数据库的知识;2.了解了一些python的知识;3.了解了一些英语知识;5.了解了一些Javaweb的知识;4.了解了一些数学建模的知识;6.了解了一些计算机网络的知识;7.在王老师的组织......
  • 2023.5.8 单例设计模式
     单例设计模式单例模式(SingletonPattern)是Java中最简单的设计模式之一。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。这种模式涉及到一个单一的类,该类负责创建自己的对象,同时确保只有单个对象被创建。这个类提供了一种访问其唯一的对象的方式,可以直接......
  • 2023.5.8 设计模式简介
    1,设计模式概述1.1软件设计模式的产生背景"设计模式"最初并不是出现在软件设计中,而是被用于建筑领域的设计中。1977年美国著名建筑大师、加利福尼亚大学伯克利分校环境结构中心主任克里斯托夫·亚历山大(ChristopherAlexander)在他的著作《建筑模式语言:城镇、建筑、构造》中描述......
  • 2023.5.8周学习总结
    一.本周计划1.继续复习图论知识2.vp一场省赛3.补cf和abc和牛客的题二.计划完成情况三.题解(158条消息)AtCoderBeginnerContest300(D-G)_scanner___yw的博客-CSDN博客四.总结1.这周打比赛的时候非常粗心,经常写错变量名,然后吃很多罚时,就很亏。......
  • 2023.5.7 职工管理系统
    1//boss.h2#pragmaonce3#include<iostream>4usingnamespacestd;5#include"worker.h"6classBoss:publicWorker7{8public:9//构造函数10Boss(intid,stringname,intdId);11//显示个人信息12voidshowInfo();......
  • 2023.5.7编程一小时打卡
    一、问题描述:编写程序提示用户输入一个班级中的学生人数n,再依次提示用户输入n个人在课程A中的考试成绩,然后计算出平均成绩显示出来。二、解题思路:首先,定义一个vector类型的成员,通过用户输入的人数进行对vector的数据添加,最后进行加和求其平均值。 三、代码实现:1#include......
  • 2023.5.7——软件工程日报
    所花时间(包括上课):6h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习并开会。我了解到的知识点:1.了解了一些数据库的知识;2.了解了一些python的知识;3.了解了一些英语知识;5.了解了一些Javaweb的知识;4.了解了一些数学建模的知识;6.了解了一些计算机网络的知识;......
  • 2023.5.7
    1//11-62#include<iostream>3#include<fstream>4#include<string>5usingnamespacestd;6classDog7{8public:9Dog(){}10Dog(intage,intwei)11{12this->m_Age=age;13this->m_W......
  • 2023.5.6 《动手学深度学习》第3、4章
    今天继续学习《动手学习深度学习》第5章:深度学习计算、第6章:卷积神经网络,今天学到的内容主要有这两章的概念。以及实现LeNet对FashionMNIST进行分类。一、理论部分:1、概念解释:1×1卷积的作用:卷积通常用于识别相邻元素间相互作用的能力,但1×1卷积不具备该能力,其主要用于调整输......