用C语言,编写一个名为fun的函数将字符串中所有的大写字母换成小写字母.高手来! C语言写函数fun 将形参字符串中的小写字母变成大写字母,大...

   www.gaoxiao88.net
#include <stdio.h>
#include <string.h>

void fun(char a[], int size)
{
int i;
for (i = 0; i < size; ++i)
{
if (a[i] >= 'A' && a[i] <= 'Z')
a[i] += 32;
}
}

void main()
{
char str[] = "This IS TEST!";
fun(str, strlen(str));
puts(str);
}

//任意字符串长度都行的,上面的却是固定的
//无用动态指针

#include <stdio.h>
void fun(char *q)
{
while(*q!='\0')
{
if (*q>= 'A'&&*q <= 'Z')
*q+= 32;
q++;
}
}

void main()
{
char *p;
p=new char;
printf("input string!:\n");
scanf("%s",p);
fun(p);
puts(p);
}

#include <stdio.h>
#include <ctype.h>

void fun(char *ch){
while(ch!=0){
ch=tolower(ch);
ch++;
}
}

int main(){
char ch[]= //添加你需要的字符串
fun(ch);
printf("%s",ch);
return 0;
}

fun(char *str)
{
while(str!=0)
toupper(str++);

}

C语言 编写一个函数,其功能是将字符串中的大写字母改为小写字母,其它字符不变。

#include "stdio.h"
void convert(char *str)
{
for(int i=0; str[i] != '\0'; i++) {
if(str[i] >='A' && str[i] <='Z') {
str[i] = str[i] - 'A' + 'a';
}
}
}
int main()
{
char str[20] = "aZcdABxDEF123";
convert(str);
printf("%s
", str);
return 0;
}

/*
s = sinCOStanCOT
转换前 : sinCOStanCOT
转换后 : SINcosTANcot
Press any key to continue
*/
#include
char *Translate(char s[]) {
int i = 0;
for(i = 0; s[i]; ++i) {
if((s[i] >= 'a') && (s[i] <= 'z')) s[i] += 'A' - 'a';
else if((s[i] >= 'A') && (s[i] <= 'Z')) s[i] += 'a' - 'A';
}
return s;
}
int main() {
char s[81];
printf("s = ");
gets(s);
printf("转换前 : %s
",s);
printf("转换后 : %s
",Translate(s));
return 0;
}

相关参考:

1. 编写一个函数fun,然后设计主函数调用函数fun。函数fun的功能是...
include<stdio.h> include<math.h> float fun(int a,int b){ float c;c = sqrt(a)+sqrt(b);return c;} int main(){ int a=12,b=20;float c;c = fun(a,b);printf("%f",c);return 0;}

c语言程序设计请编写一个函数fun,它的功能是:将ss所指字符串中所有下...
include <stdio.h> include <string.h> int main(){ int i;char ss[20];printf("请输入字符串:\\n");scanf("%s",ss);for(i=0;i<strlen(ss);i++){ if (i%2!=0){ if(ss[i]>='a')ss[i]=ss[i]-32;} } printf("%s\\n",ss);return 1;} ...

c语言:请编写一个函数fun,函数的功能是:求出N×M整型数组的最大元素及其...
int fun(int a[N][M])\/\/数组的大小是传不过去的,应该改成int fun(int a[][],int m,int n),当然你并没有用到数组的大小,所以你的写法没错,你的宏定义错了 define N 4;define M 3;不要加分号啊,宏定义不是一个语句,把宏定义后面的分号去掉就行了 ...

C语言编写:"函数fun,其功能是:在字符串中所有数字字符前加一个“*...
代码:include<stdio.h> include<string.h> void main(){ char str[40]="s23fdrt45";char *p,*p1;int len = strlen(str);scanf("%s",str);p = str;while(*p != '\\0'){ if(*p>='0' && *p<='9'){ len = strlen(p);p1 = p+len+1;while(p1>p){ p1 = *(p1-1);p1...

c语言,定义一个函数intfun(inta,intb,intc)它的功能是若a,b,c能构成...
include <stdio.h> int intfun(int a,int b,int c){ if(a+b<=c||a+c<=b||b+c<=a)\/*判断是否能构成三角形*\/ return -1; \/\/不构成三角形 else { if((a==c||a==b||b==c )&& !(a==c && a==b))\/*判断是否为等腰三角形*\/ return 2;else if(a==c && a==b)...

求C语言,用指针写,编写一函数fun,功能是,求出数组的最大元素在数组中...
} int main(void){ int a[8] = {1,4,5,3,2,4,0,1};int k = 0;int x = max_el(a, 8, &k);int i = 0;printf("数组为:\\n");for (i = 0; i < 8; i++) printf("%d\\t", a[i]);printf("\\n最大元素为%d,位置为第%d个\\n", k, x + 1);return 0;} ...

2. 编写一个函数fun,然后设计主函数调用函数fun。函数fun的功能是...
int fun(int n,int m){ int i,sum;sum=0;for(i=n;i<=m;i++){ if(i%2==0)sum=sum+i;} return(sum);} include<stdio.h> void main(){ int n,m,t,h;printf("请输入两个正整数:\\n");scanf("%d%d",&n,&m);if(n>m){ t=n;n=m;m=t;} h=fun(n,m);printf("...

C语言:编写函数fun(n),n为一个三位自然数,判断n是否为水仙花数,若是返...
include<stdio.h>int fun(int n){int a,b,c; a=n\/100; b=n\/10%10; c=n%10; return n==a*a*a+b*b*b+c*c*c;}int main(){int n; scanf("%d",&n); printf("%s\\n",fun(n)?"Yes":"No"); return 0;}

c语言编写求水仙数,从100到999之间的。用fun函数
int fun(int n){ int i,j,k,m;m=n;k=0;for(i=1;i<4;i++){ j=m%10;m=(m-j)\/10;k=k+j*j*j;} if(k==n)return 1;else return(0);} void main(){ int i;for(i=100;i<1000;i++)if(fun(i)==1)printf("%d is ok!\\n" ,i);} 水仙花数是指一个 n 位数 (...

编写取子字符串函数void fun(char s1[],char s2[],int m,int n...
int main(void){ int m,n;char s1[20];printf("Please input m and n:");scanf("%d%d",&m,&n);printf("Please input a string:");scanf("%s",s1);printf("%s\\n",f(s1,m,n));return 0;} char *f(char *s,int m,int n){ int i,j=0;char t[20];for(i=m-1;i<=...

相关评论

  • 熊鲍769: C语言,编写一个函数f(char a[],char c),如果字符串a中包含字符c返回数值1,否则返回0 -
    13535572848: #include <stdio.h>#include <stdlib.h> int f(char a[],char c){ int i,L; L = strlen(a); for(i=0;i<L;i++) if(a[i]==c) return 1; return 0; } int main () { char s1[]="abcd 123 xyz "; int k; printf("%d\n",f(s1,'2')); printf("%d\n",f(s1,'A')); return 0; }

  • 熊鲍769: C语言编程序F(X)=XN次方 -
    13535572848: 这个程序有两种方法,一种是递归调用做的,写起来不太好想,我就给你介绍最简单的一种方法吧: #include <stdio.h> int F(int a, int b) { int i=0; int j=a;//在这循环,进行b-1次,因为j=a,所以在第一次的时候就已经进行了a的平方了,所以需要...

  • 熊鲍769: C语言,写一个函数,计算f(x)的在[1,2]区间的定积分.f是函数的形参.利用这个函数计算sin(x)的定积分 -
    13535572848: 12345678910 //#include "stdafx.h"//vc++6.0加上这一行.#include "stdio.h"#include "math.h" intmain(void){ doublex,c=0.00001,sum; for(sum=0.0,x=1.0;x sum+=sin(x)*c; printf("The result is %f\n",sum); return0; }

  • 相关话题

    ap在线精英在线最新简短笑话,好笑的段子,搞笑句子,男女朋友校园冷笑话,搞笑歌词对白台词,夫妻搞笑对话,手机流行笑话,逗人笑的动物经典笑话,最新幽默搞笑图文,好笑的视频分享给朋友
    若有事情,请联系电邮
    © <搞笑吧