ftsg.net
当前位置:首页 >> 编写程序,输入一个字符串,计算出这个字符串的长... >>

编写程序,输入一个字符串,计算出这个字符串的长...

#include "stdio.h" void main() { char a[80]; int i=0; gets(a); while(a[i]!='\0')i++; printf("%d",i); }

public class Java6 {public static void main(String[] args) {Scanner sc=new Scanner(System.in);System.out.println("请输入一个字符串:");String str=sc.nextLine();System.out.println("请输入截取的开始位置:");int a = sc.nextInt();S...

import java.util.Scanner; public class lli { public static void main(String[] args) { Scanner ss=new Scanner(System.in); String s=new String(); System.out.print("请输入字符串:"); s=ss.next();//输入字符串! System.out.println("长...

#include #include #define MAX_SIZE 20 // 字符串的最大长度int main() { int length = 0, i; char str[MAX_SIZE]; gets_s(str); // 输入字符串 // 遍历字符串的每一个字符得出其长度 for (i = 0; str[i] != '\0'; i++) { length++; } printf("...

int i = 0; char a[100] = "Hello world!"; while(a[i] != '\0') { i++; } printf("%d",i);

#include void main() { char str[80]; int len=0,i=0; gets(str); while(str[i])len++; printf("The length of %s is %d.\n",str,len) ; }

#include #include int main() { char s[1000]; int l,i; scanf("%s",s); l=strlen(s); for(i=l-1;i>=0;i--) { printf("%c",s[i]); } printf("\n"); return 0; }

#include #include int main() { char data[33]; int dota[33]; int i, j, num, len; gets(data); len = strlen(data); for (i = 0; i

C代码参考 #include int main(){char buf[0x100];scanf("%[^\n]", buf);int len = 0, maxlen = 0;for (int i = 0; buf[i]; i++){if (buf[i] == ' '){if (len > maxlen) maxlen = len;len = 0;}else len++;}if (len > maxlen) maxlen = len;print...

#include "stdio.h" int fun(char *s) { int i=0; while(*s++)i++; return i; } void main() { char a[81]; gets(a); printf("%d\n",fun(a)); }

网站首页 | 网站地图
All rights reserved Powered by www.ftsg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com