⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pex6_1.cpp

📁 数据结构C++代码,经典代码,受益多多,希望大家多多支持
💻 CPP
字号:
#include <iostream.h>
#pragma hdrstop

#include "wex6_5.h"

void main(void)
{
	int a = 3, b = 5;
	float x = 2.987, y = -6.532;
	char s[20], t[20];

	// output original values of a/b and x/y
	cout << "Original a/b and x/y: ";
	cout << a << '/' << b << "  " << x << '/' << y << endl;
	
	// swap a/b and x/y
	Swap(a,b);
	Swap(x,y);
	
	// print the swapped values
	cout << "Swapped a/b and x/y: ";
	cout << a << '/' << b << "  " << x << '/' << y
		 << endl << endl;
	
	// enter two strings s and t. strings may contain blanks
	// and terminate when newline is typed
	cout << "Enter string s: ";
	cin.getline(s,20,'\n');
	cout << "Enter string t: ";
	cin.getline(t,20,'\n');

	// swap strings s and t
	Swap(s,t);
	// print the swapped strings
	cout << "The swapped values of s and t are: ";
	cout << '\'' << s << "'  " << '\'' << t << '\'' << endl;
}

/*
<Run>

Original a/b and x/y: 3/5  2.987/-6.532
Swapped a/b and x/y: 5/3  -6.532/2.987

Enter string s: hello
Enter string t: to the world
The swapped values of s and t are: 'to the world'  'hello'
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -