我如何对我的程序进行编码以仅查看程序的索引 7 来查找此代码最后一部分的两个字母中的一个。我是新手,已经为此工作了一段时间。这让我很难过,我一直在阅读这本书并下载一些视频,但我似乎没有得到这个。
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cstring>
#include <cctype>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string string;
// get character
cout << "\nEnter Email address ID: ";
getline(cin, string );
cout << endl;
{
if (!isalpha(string[0]))
cout << "first charactor needs to be a Letter"<< endl;
if (!isalpha(string[1]))
cout << "Second charactor needs to be a letter"<< endl;
if (!isdigit(string[2]))
cout << "Third charactor needs to be a number"<< endl;
if (!isdigit(string[3]))
cout << "Fourth charactor needs to be a number"<< endl;
if (!isdigit(string[4]))
cout << "Fifth charactor needs to be a number"<< endl;
if (!isdigit(string[5]))
cout << "Sixth charactor needs to be a number"<< endl;
if (!isdigit(string[6]))
cout << "Seventh charactor needs to be a number"<< endl;
if(!isalpha(string[7]))
if(string != "n" || string !="p")
cout << "Eight charactor needs to be a N or P"<< endl;
{
}
cout << endl;
system("pause");
return 0;
}
}