用函数的调用知识求出a*b+c*d的值,还有求定义一个字符数组并将其中的小写字母换成大写
- 提问者网友:寂寞梧桐
- 2021-05-16 16:26
- 五星知识达人网友:孤独入客枕
- 2021-05-16 17:35
#include<iostream>
using namespace std;
#define N 10
int f1(int a,int b,int c,int d)
{
return a*b+c*d;
}
void f2(char *p)
{
for(int i = 0; i < N; i++)
{
if(p[i] >= 'a' && p[i] <= 'z')
p[i] = p[i] - 32;
}
}
int main()
{
int i;
cout<<f1(1,2,3,4)<<endl;
char ch[N];
for( i = 0; i< N; i++)
cin>>ch[i];
f2(ch);
for( i = 0; i< N; i++)
cout<<ch[i]<<" ";
return 0;
}
- 1楼网友:杯酒困英雄
- 2021-05-16 18:24
=============================
#include<stdio.h> long fun(int, int, int, int); void strToSTR(char *p); void main() { int a,b,c,d; long sum; char str[] = {"abcdefg"}; printf("请输入a,b,c,d的值(用,隔开):"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); sum = fun(a,b,c,d); printf("a*b+c*d = %ld\n",sum); printf("字符%s转换成大写后 = ",str); strToSTR(str); printf("%s",str); } long fun(int a, int b, int c, int d) { return (a*b+c*d); } void strToSTR(char *p) { int i; for(i = 0; p[i] != '\0'; i ++) p[i] -= 32; }