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

📄 pex2_8.cpp

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

void main(void)
{
	char decryptstr[] = "ghfpltbkvznmiagodxyejwrsuc";
	
	ifstream  fin;
	char      line[80];
	int       i;
	
	fin.open("crypfile", ios::in | ios::nocreate);
	if (!fin)
	{
		cerr << "Cannot open crypfile!" << endl;
		exit(1);
	}
	
	// read lines from fin until end of file
	while(fin.getline(line,80,'\n'))
	{
		i = 0;
		// look at each character of the NULL-terminated string
		while (line[i])
		{
			// translate each alphabetic character
			if (isalpha(line[i]))
				// convert to lower case and translate
				line[i] = decryptstr[tolower(line[i])-'a'];
			i++;
		}
		cout << line << endl;
	}
}

/*
<Run>

this is a data file that
tests the solution to programming
exercises 2.7 and 2.8.
*/

⌨️ 快捷键说明

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