字符串转化为数组
来源:互联网 发布:cf卡海豹突击队软件 编辑:程序博客网 时间:2024/05/17 03:25
输入为字符数组时:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;char a[1010];int b[1010];int n;int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) { cin>>a[i]; b[i]=a[i]; } for(int i=1;i<=n;i++) { cout<<b[i]-'0'<<" "; } return 0;}
输入为字符串时:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int a[1001];string s;int main(){ cin>>s; int l=s.length(); for(int i=0;i<l;i++) { a[i]=s[i]; } for(int i=0;i<l;i++) { cout<<a[i]-'0'<<" ";//cout<<a[i]-'a'<<" "; } return 0;}
阅读全文
0 0
- 字符串转化为数组
- 字符串转化为数组,数组转化为字符串。
- 把数组转化为字符串
- json数组转化为字符串
- 将字符串转化为数组
- 字符串转化为二维数组
- iOS 数组转化为字符串
- 字符串转化为整型数组
- 将字符串数组转化为字符串
- 将字符串转化为字符串数组
- 把字符串转化为字符数组
- js关联数组转化为json字符串
- js把字符串转化为对象、数组
- php二维数组转化为字符串
- 数组、字典转化为json字符串
- java中实现数组转化为字符串
- 整数和数组转化为字符串
- php二维数组转化为字符串
- 元素互换之逆置算法
- linux进程管理
- 剑指offer--矩形覆盖
- 随机森林与GBDT
- 仿淘宝京东评分控件
- 字符串转化为数组
- Java基础之Java概述
- 小白成长记——Java基础之访问控制符
- POJ 3279 Fliptile——开关问题
- 最少转弯问题
- @ResponseBody 无法将实体类传回页面 详解
- 动态规划中级教程 279. Perfect Squares
- DAY49 CSS基础1
- mac Python 图形用户界面学习