F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
大视野在线测评-欢迎您
[ New Thread ]
Problem 4566 >> 编译器都不优化的吗?
Bobh @ 2019-02-14 11:00:02
[ Quote ] [ Edit ] [ Delete ] 1#
遍历字符串的时候这样写就回T:
for(int i=0;i<strlen(s);i++){...}

这样写就能A:
for(int i=0,n=strlen(s);i<n;i++){...}

。。。
zjp_shadow @ 2019-02-14 14:56:55
[ Quote ] [ Edit ] [ Delete ] 2#
确实不能优化啊,如果循环中存在修改 s 长度的操作的话,编译器就会是个错的优化啦。

首先保证优化是正确的,才优化啊。
Bobh @ 2019-02-18 10:08:13
[ Quote ] [ Edit ] [ Delete ] 3#
@zjp_shadow 谢谢解答
[Top] [Previous Page] [Next Page]

HOME Back