做公司网站的公司,外贸网站联系方式模板免费,品牌网站建设公司哪家好,上海由多少家网站建设公司字符串的多组输入格式
scanf(%c, ch)读取单个字符#xff0c;用EOF作为结束的判断标志。 刷题记录#xff1a;[题] 查找最大元素 #字符输入 逐个字符手动读取#xff0c;因为题目的要求#xff0c;要对每个字符逐个操作#xff0c;所以就输入的时候顺便…字符串的多组输入格式
scanf(%c, ch)读取单个字符用EOF作为结束的判断标志。 刷题记录[题] 查找最大元素 #字符输入 逐个字符手动读取因为题目的要求要对每个字符逐个操作所以就输入的时候顺便比较大小了。 我的理解是每个字符串末尾会有\0字符然后整个所有组的输入都齐了之后会有一个EOF。 #includebits/stdc.h
using namespace std;
int main() {char s[100000];while(scanf(%c, s[0]) ! EOF) {}return 0;
}gets(str)读取char[N]定义的字符串不用加结束条件进行判断。 能读空格遇到换行才结束。 刷题记录[题] 首字母变大写 #字符输入 #includebits/stdc.h
using namespace std;
char str[101];
int main() {while(gets(str)) {}return 0;
}从下面例子可以看到这样读进去的字符串会在最后面加上\0 #includebits/stdc.h
using namespace std;
char str[101];
int main() {gets(str);for(int i 0;;i ) {if(str[i] \0) {printf(遇到\\0了在第%d位这里, i);break;}elseprintf(%c, str[i]);}return 0;
}getline(cin, s)读取string定义的字符串不用加结束条件进行判断。 能读空格遇到换行才结束。 刷题记录[题] 首字母变大写 #字符输入 #includebits/stdc.h
using namespace std;
int main() {string s;while(getline(cin, s)) {}return 0;
}从下面例子可以看到这样读进去的字符串会在最后面加上\0 #includebits/stdc.h
using namespace std;
int main() {string s;getline(cin, s);for(int i 0;;i ) {if(s[i] \0) {printf(遇到\\0了在第%d位这里, i);break;}elseprintf(%c, s[i]);}return 0;
}