工业物联网集成了微电子计算技术、通信技术、云平台、大数据技术以及工业生产运营技术,是未来物联网运用最重要的方向。
作者:KingKa Wu 欢迎任何形式的转载,但请务必注明出处。 限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。
  • 逆转字符串——输入一个字符串,将其逆转并输出。

 

Python:

  1. def rev(s):
  2. return (s[::-1])
  3. s =input("请输入一个字符串:")
  4. a = rev(s)
  5. print (a)

C++:

第一种:使用string.h中的strrev函数

            

  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int main()
  5. {
  6. /*char s[100];
  7. cout<<"请输入一个字符串:"<<endl;
  8. cin>>s;*/
  9. char *s;
  10. cin>>s;
  11. strrev(s);
  12. cout<<s<<endl;
  13. return 0;
  14. }

第二种:使用algorithm中的reverse函数

  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7. string s ;
  8. cout<<"请输入一个字符串:"<<endl;
  9. cin>>s;
  10. reverse(s.begin(),s.end());
  11. cout<<s<<endl;
  12. return 0;
  13. }
  14. 三种:自己编写
  1. #include <iostream>
  2. using namespace std;
  3. void Reverse(char *s,int n){
  4. for(int i=0,j=n-1;i<j;i++,j--){
  5. char c=s[i];
  6. s[i]=s[j];
  7. s[j]=c;
  8. }
  9. }
  10. int main()
  11. {
  12. char *p;
  13. cin>>p;
  14. Reverse(p,100);
  15. cout<<p<<endl;
  16. return 0;
  17. }

 

 

  • 拉丁猪文字游戏——这是一个英语语言游戏。基本规则是将一个英语单词的第一个辅音音素的字母移动到词尾并且加上后缀-ay(譬如“banana”会变成“anana-bay”)。可以在维基百科上了解更多内容。

python:

  1. s = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
  2. connect = "ay"
  3. foo = input('请输入一个字符串:')
  4. for i in foo:
  5. if i not in s:
  6. foo = foo.replace(i, '', 1)+"-"+i+connect
  7. print(foo)
  8. break
  9. else:
  10. continue

c++:

 

  • 统计元音字母——输入一个字符串,统计出每个元音字母的数量。

Python:

 

 

C++:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
posted on 2017-08-16 17:42  KingKa_Wu  阅读(160)  评论(0编辑  收藏  举报