5
求最大公约数
1.
while(a!=b)
{
if(a>b)
a-=b;
else(a<b)
b-=a;
} cout<<a;
2.
d=a%b;
while(d!=0)
{
a=b;
b=d;
d=a%b;
} cout<<b;
定义字符串 string
字符串函数 strlen(求长度);strcpy(复制后到前);strncpy(后前n个字符复制到前);strcat(连接);strncat(后的前n个字符连接);strcmp(比较(ASCII));strchr(在字符串中查找字符a);
1.
while(a!=b)
{
if(a>b)
a-=b;
else(a<b)
b-=a;
} cout<<a;
2.
d=a%b;
while(d!=0)
{
a=b;
b=d;
d=a%b;
} cout<<b;
定义字符串 string
字符串函数 strlen(求长度);strcpy(复制后到前);strncpy(后前n个字符复制到前);strcat(连接);strncat(后的前n个字符连接);strcmp(比较(ASCII));strchr(在字符串中查找字符a);
全部评论
相关推荐
点赞 评论 收藏
分享