UVA_325_Identifying Legal Pascal Real Constants

#include<iostream>    
#include<sstream>    
#include<string>    
#include<vector>    
#include<list>    
#include<set>    
#include<map>    
#include<stack>    
#include<queue>    
#include<algorithm>  
#include<bitset>
#pragma warning(disable:4996)    
using std::cin;
using std::cout;
using std::endl;
using std::stringstream;
using std::string;
using std::vector;
using std::list;
using std::pair;
using std::set;
using std::multiset;
using std::map;
using std::multimap;
using std::stack;
using std::queue;
using std::priority_queue;
using std::bitset;
bool check(const string &str)
{
	int state = 0;//当前状态
	for (size_t i = 0; i < str.size(); i++)
	{
		switch (state)
		{
		case 0: 
		{
			if (str[i] == '+' || str[i] == '-' || isdigit(str[i]))
			{
				state = 1;
			}
			else
			{
				return false;
			}
		}break;
		case 1:
		{
			if (isdigit(str[i]))
			{
				;
			}
			else if (str[i] == '.')
			{
				state = 2;
			}
			else if (str[i] == 'E' || str[i] == 'e')
			{
				state = 4;
			}
			else
			{
				return false;
			}
		}break;
		case 2:
		{
			if (isdigit(str[i]))
			{
				state = 3;
			}
			else
			{
				return false;
			}
		}break;
		case 3:
		{
			if (isdigit(str[i]))
			{
				;
			}
			else if (str[i] == 'E' || str[i] == 'e')
			{
				state = 4;
			}
			else
			{
				return false;
			}
		}break;
		case 4:
		{
			if (str[i] == '+' || str[i] == '-' || isdigit(str[i]))
			{
				state = 5;
			}
			else
			{
				return false;
			}
		}break;
		case 5:
		{
			if (isdigit(str[i]))
			{
				;
			}
			else
			{
				return false;
			}
		}break;
		default:return false;
		}
	}
	if (state == 3 || state == 5)
	{
		return true;
	}
	return false;
}
int main()
{
	//freopen("input.txt", "r", stdin);    
	//freopen("output.txt", "w", stdout);
	string str;
	while (cin >> str)
	{
		if (str[0] == '*')
		{
			break;
		}
		cout << str;
		if (check(str))
		{
			cout << " is legal." << endl;
		}
		else
		{
			cout << " is illegal." << endl;
		}
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果bs.report_no是varchar类型的,并且其中只包含数字,你可以使用以下SQL语句进行排序: ```sql SELECT bs.report_no, bs.sample_id, bs.test_id, bs.service_type, bs.sample_name, bs.total_fee, bs.receivable_fee, bs.sample_no, bs.ranges, bs.grade, bs.sample_remark AS remark, bs.factory, bs.item_name, bs.apply_dept, bs.specification, bs.factory_number, bs.calibrat_point, bs.mandatory_flag, bs.inspection_type, bs.report_org_name, bs.plan_complete_date, bs.standard_instrument_name, bs.bleeding_site_name, bs.arrive_date, DATEDIFF(bs.plan_complete_date, NOW()) AS surplus_days, bs.order_no, bs.order_type, bs.customer_name, bs.order_id, bs.business_type, bs.group_id, bs.group_name, bs.item_id, bs.is_merge, bs.pass_time, bs.audit_time, bs.report_id, bs.compile_time, bs.generate_time, bs.pass_user_name, bs.audit_user_name, bs.compile_user_name, bs.report_state, bs.is_just_certificate, bs.label_price, bs.labor_cost, bs.product_type, bs.batch_number, bs.original_number, bs.type_no, bs.template_id, bs.template_version, bs.standard_instrument_id, bs.standard_instrument_name, bs.report_query_code, bs.test_user_id, bs.test_user_name, bs.test_time, bs.review_user_id, bs.review_user_name, bs.review_time, bs.or_number, bs.test_result, bs.test_result_text, bs.test_date, bs.test_address, bs.result_value, bs.unit, bs.test_dept_id, bs.test_dept_name, bs.sample_mass, bs.form, bs.color, bs.clarity, bs.amplification_detection, bs.precious_metal, bs.remarks, bs.photo, bs.identifying_code, bs.diamond_quality, bs.hand_ring, bs.craft, bs.instrument_photo, bs.customer_item_basis, bs.quality_photo, bs.check_point, bs.check_code, bs.mass_unit, bs.manufacturer_name, bs.manufacturer_addr, bs.result_sample_describe AS sampleDescribe, bs.test_rule AS metalRuleIdsStr, bsa.attach_id FROM view_sample_info bs JOIN bus_sample_report bsr ON bs.report_id = bsr.id JOIN bus_sample sa ON bsr.sample_id = sa.id JOIN bus_sample_attr bsa ON sa.id = bsa.id ORDER BY CAST(bs.report_no AS UNSIGNED) ASC; ``` 这将按照bs.report_no的数字值从小到大对结果进行排序。如果bs.report_no中包含非数字字符,可能会导致排序不正确。在这种情况下,你可能需要先清洗数据,使得bs.report_no只包含数字。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值