Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
yuanmingtao
C-
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
C-
/
1.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
43 lines (36 loc) · 1.44 KB
master
Breadcrumbs
C-
/
1.cpp
Copy path
Top
File metadata and controls
Code
Blame
43 lines (36 loc) · 1.44 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* 功能:将结构对象的两个域值相加,乘以2再加50 */
#include <iostream> //包含头文件
using namespace std; //使用命名空间
int result(int, int); //result函数的原型声明
//const int k = 2; //定义常量
//const int k(2); //定义常量并使用构造函数方法初始化
#define k 2 //k只是一个名字,并不占用存储空间,存在类型问题
extern const int d; //外部变量d
struct Point{ //定义结构Point
int x,y; //定义结构成员x和y
};
int main1() //主程序
{
//主程序开始
int z(0), b(50); //初始化整数对象(构造函数语法)
Point a; //定义结构对象a
cout << "输入两个整数(以空格区分):"; //输出提示信息
cin >> a.x >> a.y; //接受输入数值
z = (a.x + a.y) * k; //计算结果
z = result(z, b); //计算结果
cout << "计算结果如下:" << endl; //输出提示信息
cout << "((" << a.x << " + " << a.y //输出信息
<< ") *" << k << ") +" << b //输出信息
<< "=" << z //输出结果
<< endl; //换行
return 0; //主函数main的返回值
} //主函数结束
//***************************
//* 函 数:result *
//* 参 数:整型对象 a 和 b *
//* 返回值:整型对象 *
//***************************
int result(int a, int b)
{
return a + b; //返回a + b
}
You can’t perform that action at this time.