python與平臺有關嗎_后端開發
Python與平臺無關,因為Python是跨平臺的語言,Python作為腳本語言,是解釋執行的,所以能跨平臺,前提是必須要有一個對應的解釋器。
具體請看實例:
python中count函數的用法詳解_后端開發
python中count函數用于統計字符串里某個字符出現的次數,語法為str.count(“char”,start,end)。比如使用“aabbcc”.count(“b”)可以獲得“b”在字符串“aabbcc”中出現的次數。
免費視頻教程推薦:c語言視頻教程
#include
#include
#include
char *right(char *ms,int len); /*截取一個字符串尾部長為len個字符的子串*/
void main()
{
long a;
int len;
char as[10];
char ms[20];
printf("求[1,10000]中的同構數:\n");
for(a=1;a<=10000;a++)
{
ultoa(a,as,10); /*數a轉換為字符串,存入as*/
len=strlen(as);
ultoa(a*a,ms,10);
if(strcmp(as,right(ms,len))==0) /*比較字符串as與ms長為len的子串是否相等*/
printf("%s 其平方為 %s\n",as,ms); /*相等就是同構數,輸出結果*/
}
system("pause");
}
char *right(char *ms,int len) /*截取字符串尾部長為len子串的函數*/
{
int i,j;
for(i=0;i
for(j=0;j
return ms;
}
相關文章教程分享:c語言教程