当前位置:   article > 正文

L1-064 估值一亿的AI核心代码 (20分)(极短代码)_估值一亿的ai核心代码 c语言

估值一亿的ai核心代码 c语言

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	getchar();
	while (n--)
	{
		string s;
		getline(cin, s);
		cout << s << endl;
		while (s[0] == ' ')	s.erase(s.begin());
		while (s[s.length() - 1] == ' ')	s.erase(s.end() - 1);
		for (int i = 0; i<s.length(); i++)
			if (s[i] == ' ')
			{
				while (s[i + 1] == ' ')	s.erase(s.begin() + i + 1);
				if (!isalnum(s[i+1]))	s.erase(s.begin() + i);
			}
		for (int i = 0; i<s.length(); i++)
			if (s[i] >= 'A'&&s[i] <= 'Z'&&s[i] != 'I')s[i] -= 'A' - 'a';
		for (int beg = 0;; beg++)
		{
			beg = s.find("can you", beg);
			if (beg == -1)break;
			if ((!beg||!isalnum(s[beg-1]))&&(beg+7==s.length()||!isalnum(s[beg+7])))
				s.replace(beg,7,"A can");
		}
		for (int beg = 0;; beg++)
		{
			beg = s.find("could you", beg);
			if (beg == -1)break;
			if ((!beg||!isalnum(s[beg-1]))&&(beg+9==s.length()||!isalnum(s[beg+9])))
				s.replace(beg,9,"A could");
		}
		for (int beg = 0;; beg++)
		{
			beg = s.find("I", beg);
			if (beg == -1)break;
			if ((!beg||!isalnum(s[beg-1]))&&(beg+1==s.length()||!isalnum(s[beg+1])))
				s.replace(beg,1,"you");
		}
		for (int beg = 0;; beg++)
		{
			beg = s.find("me", beg);
			if (beg == -1)break;
			if ((!beg||!isalnum(s[beg-1]))&&(beg+2==s.length()||!isalnum(s[beg+2])))
				s.replace(beg,2,"you");
		}
		for (int i=0;i<s.length();i++)
		{
			if (s[i] == '?')s[i] = '!';
			if (s[i] == 'A')s[i] = 'I';
		}
		cout << "AI: " << s << endl;
	}
	return 0;
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/277213
推荐阅读
相关标签
  

闽ICP备14008679号