0分求助!!!
查看原帖
0分求助!!!
1297705
Ken369楼主2024/12/2 19:15

大佬帮帮忙!!!

//@XiaoZheng
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
//if you need the test,you can look at the line 85
 
//main
int main()
{
	char a[101];
	char put[101];
	string str_input;
	int i=0,len=0;
	bool b_big=false,b_small=false,b_number=false,b_special=false;	//the flag
	bool b_wrong=false;
	//gets
	gets(a);
	//lenth
	int lenth=strlen(a);
	//Debug
	/*for(i=0;i<lenth;i++)
	{
		cout<<a[i];
	}
	cout<<endl;*/
	//the first to the a-1 one
	for(i=0;i<lenth;i++)
	{
		put[len]=a[i];
		//if
		if(a[i]>='A'&&a[i]<='Z')
		{
			b_big=true;
			len++;
		}
		else if(a[i]>='a'&&a[i]<='z')
		{
			b_small=true;
			len++;
		}
		else if(a[i]>='0'&&a[i]<='9')
		{
			b_number=true;
			len++;
		}
		else if(a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$')
		{
			b_special=true;
			len++;
		}
		else if(a[i]==','||i==lenth-1)	//we will print the right sentences here
		{
			if(((b_big&&b_small)||(b_big&&b_number)||(b_small&&b_number))&&b_special&&(len>=6&&len<=12)&&!b_wrong)
			{
				if(a[i]==',')
				{
					for(int j=0;j<len-1;j++)
					{
						cout<<put[j];
					}
					cout<<endl;
				}
				else if(i==lenth)
				{
					for(int j=0;j<len;j++)
					{
						cout<<put[j];
					}
					cout<<endl;
				}
			}
			else
			{
				//cout<<"wrong format"<<endl;	//debug
			}
			len=0;
			b_big=false;
			b_small=false;
			b_number=false;
			b_special=false;
			b_wrong=false;
			//cout<<i<<endl;	//debug
		}
		else
		{
			b_wrong=true;
			len++;
		}		
	}
	//the last one(don't forget it ^-^)-but I don't need it,because I have the line 47
	/*if(((b_big&&b_small)||(b_big&&b_number)||(b_small&&b_number))&&b_special&&(len>=6&&len<=12)&&!b_wrong)
	{
		for(int j=0;j<len;j++)
		{
			cout<<put[j];
		}
		cout<<endl;
	}*/
	// 
	//don't forget the "return"!
	return 0;
}
//I think you will need the test(down!)
//(test)->seHJ12!@,sjdkffH$123,sdf!@&12HDHa!,123&^YUhg@!,aA123456@
2024/12/2 19:15
加载中...