c 字符串数字最后一位 加1

[复制链接]
查看11 | 回复5 | 2012-8-21 15:42:22 | 显示全部楼层 |阅读模式
#include #include int main(){char szBuffer[255];scanf("%s",szBuffer);szBuffer[ strlen(szBuffer) - 1 ]++; //定位到最后一位并+1puts(szBuffer);return 0;}...
回复

使用道具 举报

千问 | 2012-8-21 15:42:22 | 显示全部楼层
这人也太懒了!!这是fobnn的代码改一下就好了:#include #include int main(){char szBuffer[]="abcdef_1111111000_2222222601_1333749600";int a,b,c;char cs[10];sscanf(szBu...
回复

使用道具 举报

千问 | 2012-8-21 15:42:22 | 显示全部楼层
char p[] = "abcdef_1111111000_2222222601_1333749600";p[strlen(p)-1] += 1; //最后一位 ASIC 码加1
注意不能修改常量字符串; char* p = "abcdef_1111111000_2222222601_1333749600";p[strlen...
回复

使用道具 举报

千问 | 2012-8-21 15:42:22 | 显示全部楼层
int main(){ char m[]={'a','b','c','d','e','f','_','1','1','1','1','1','1','1','0','0','0','_','2','2','2','2','2','2','2','6','0','1','_','1','3','3','3','7','4','9','6','0','0',...
回复

使用道具 举报

千问 | 2012-8-21 15:42:22 | 显示全部楼层
#includevoid main(){ char str[]="abcdef_1111111000_2222222601_1333749600"; int i=0; while(str!='\0') {i++;if(str=='\0') str[i-1]+=1; } pr...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行