指针编程题
㈠ C语言指针编程题,求助大佬
#include <stdio.h>
int main()
{
int a;
int b;
int *pa = &a;
int *pb = &b;
printf("请输入a和b的值: ");
scanf("%d %d", pa, pb); //在高版本的vs里要用scanf_s
printf("a和b的和是: %d\n", *pa + *pb);
printf("a和b的差是: %d\n", *pa - *pb);
printf("a和b的积是: %d\n", *pa * *pb);
printf("a和b的商是: %f\n", *pa * 1.0 / *pb);
return 0;
}
㈡ C语言指针一道简单的编程题
按照你的要求编写的C语言程序如下
include<stdio.h>
intmain()
{
inta,b;
int*p=&a;
a=30;
printf("a=%d ",*p);
p=&b;
scanf("%d",p);
a=*p+24;
printf("a=%d,b=%d",a,b);
return0;
}
运行结果
a=30
76
a=100,b=76
㈢ C语言指针编程题,求大神解答
#include "stdio.h"
void fun(int a[][6],int n,int m,int *odd,int *even)
{int i,j;
*odd=*even=0;
for(i=0; i<n; i++)
for(j=0; j<m; j++)
a[i][j]%2?*odd+=a[i][j]:*even+=a[i][j];
}
int main()
{ int n,m,i,j,a[5][6],odd,even;
for(i=0; i<5; i++)
{ for(j=0; j<6; j++)
{ a[i][j]=i*6+j+1;
printf("%4d",a[i][j]);
}
printf(" ");
}
fun(a,5,6,&odd,&even);
printf("奇数之和=%d 偶数之和=%d ",odd,even);
return 0;
}
㈣ C语言指针编程题,求助大神
#include<stdio.h>
int n;
void multiplyArray(int *a,int m){
int *p =a+n;
for(;a!=p;a++)
*a*=m;
a-=n;
}
int main(){
int m;
scanf("%d%d",&n,&m); //输渗蚂亏入数组长丛神度物悉N和乘数 M
int *a=new int[n];
int *p=a;
int *q=a+n;
for(;p!=q;p++)//输入N个元素
scanf("%d",p);
multiplyArray(a,m);//调用函数对元素乘以M
printf("%d",*a);//输出第一个元素不加空格
a++;
for(;a!=q;a++){
printf(" %d",*a);//前面加空格输出元素使尾部无空格
}
}