6月11-15号-check-检查输入字符串的正确性
来源:互联网 发布:下载gif软件 编辑:程序博客网 时间:2024/04/28 18:46
检查-i和-o后面的字符串的正确性!
#include<stdio.h>
#include<iostream.h>
#include<fstream.h>
#include <windows.h>
bool check(char str[]);
main()
{
char a[100]="",str[100]="";
int i=0,j=0;
bool f=false;
while(!f)
{
cin.clear();
cin.getline(a,100);
// while(a[i])
// {
// if(a[i]==' ')i++;
// str[j++]=a[i++];
// }//qu diao kong ge
f=check(a);
// cout<<f<<endl;
}
//cin.clear();
//cin.getline(a,100);
// cout<<a<<endl;
// cin.clear();
//cin.getline(a,100);
//cout<<a<<endl;j
//cout<<str<<endl;
}
bool check(char str[])
{
char in[50]="",out[50]="";
int i=0,j=0,k=0,b[2]={0},flag=0;
while(str[i])
{
if(str[i]==' ')i++;
if(str[i]=='-')
{
i++;
if(str[i]=='I'||str[i]=='i')
{
b[0]++;
i++;
while(str[i]!='-'&&str[i])
{
if(str[i]==' '&&str[i+1]!='-') i++;
in[j++]=str[i++];
//cout<<in<<endl;
}
i--;
if(b[0]==2)
{
cout<<"command error! please put in again"<<endl;
return false; //b[0]=0;
//i=0;モテflagタエア・ヌネサコルハ菠・
//cin.clear();
//cin.getline(a,100);
}
}
else if(str[i]=='O'||str[i]=='o')
{
b[1]++;
i++;
while(str[i]!='-'&&str[i])
{
if(str[i]==' '&&str[i+1]!='-')i++;
out[k++]=str[i++];
}
i--;
if(b[1]==2)
{
cout<<"command error! put in again"<<endl;
return false;
}
}
//else if(a[i]==' ')
//{
// i++;
//}
else
{
cout<<"command error! put in again!"<<endl;
return false;
}
}
// in[j++]=a[i];
i++;
}
k=0;j=0;
fstream file;
while(in[j])
{
if(in[j]=='.')
{
flag=1;
if((in[j+1]=='P'&&in[j+2]=='R'&&in[j+3]=='J')||(in[j+1]=='p'&&in[j+2]=='i'&&in[j+3]=='j'))
{ cout<<"yes!"<<endl;
file.open(in,ios::in);
if(!file)
{
cout<<"file is not exist ! put in again!"<<endl;
return false;
}
else cout<<"file is exist!"<<endl;
}
else
{
cout<<"file is wrong put in again!"<<endl;
return false;
}
}
j++;
}
if(flag==0)
{
cout<<"in file is wrong!put in again"<<endl;
return false;
}
while(out[k])
{
if(out[k]=='.')
{
cout<<"file jia is wrong put in again!"<<endl;
return false;
}
k++;
}
if(out[0]=='\0')
{
//cout<<out<<endl;
GetCurrentDirectory(100,out) ;//如果没有入力就 默当前路径
}
else
{
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(out, &wfd);
if ((hFind != INVALID_HANDLE_VALUE) && (wfd.dwFileAttributes &&FILE_ATTRIBUTE_DIRECTORY))
{
cout<<"directory is exist"<<endl;
}
else
{
cout<<"directory is not exist put in again!"<<endl;
return false;
}
FindClose(hFind);
}
// cout<<a<<endl;
cout<<in<<endl;
cout<<out<<endl;
cout<<i<<endl;
return true;
}
- 6月11-15号-check-检查输入字符串的正确性
- 检查电话号码的正确性
- ASP.NET利用CustomValidator的ClientValidationFunction与OnServerValidate来double check资料输入的正确性
- jQuery版本的文本输入框检查器Input Check
- 输入网址,字符串检查
- 验证身份证号输入的正确性[转]
- Javascript 验证输入表单的正确性
- JS判断输入日期的正确性
- JS判断输入日期的正确性
- JS判断输入日期的正确性
- 检查窗体中数据填写正确性的方法
- VBA中关IP地址正确性的检查
- 检查窗体中数据填写正确性的方法
- 利用栈检查程序中成对符号使用的正确性
- check a string is numeric or not? 检查字符串是否是数值型的
- 检查输入的字符串中是否有空格存在
- 字符串的长度Check
- 字符串的长度Check
- Handler的另外一种用法(HandlerThread)
- Android之Handler用法总结
- Discuz X2 建站指南(结合个人网站总结)
- kettle加解密算法
- 根据地球上任意两点的经纬度计算两点间的距离
- 6月11-15号-check-检查输入字符串的正确性
- Android Handler的使用
- C# lock使用
- Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
- 不要把大脑当做磁盘
- 继承、初始化及类的加载
- windows和ubuntu下的adb调试环境的搭建
- 日期取整年整月
- ArcGIS for Android 中MapView截图实现方法