c語言指針編程題
⑴ c語言指針,求題目詳解
您好,很高興回答您的問題。
您的這個程亂羨序,主函數中的第一句話表示p1 和str都是數組名,指向數組中的第一個元素。p2是指針變數,指向的是字元型數據。第二句話表示p2這個指針變數指向的是包含有abc等三個元素的字元型數組。strcpy(str+1,strcat(p1,p2))表示現將p2所指向的內容添加到p1這個數組的結尾處,並且存放在p1中,那麼做完吵伏之後p1里的內容為abcabc。接下來執行strcpy(str+1,p1)表示把此時嘩碰拍p1中的內容拷貝到str中,是從str+1這個位置開始。因為str是數組名,指向的是數組的第一個元素,那麼str+1,就是從str數組的第二個元素位置開始,所以最終得到的結果就是aabcabc。
以上就是我對這個問題的回答,希望您能幫助到您。
⑵ 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>
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);//前面加空格輸出元素使尾部無空格
}
}
⑷ c語言 指針部分編程題
完整程序如下:
#include <stdlib.h>
main(){
int a,b,c;
int *p1,*p2,*p3;
printf("please input 3 int data\滑吵n");
scanf("%d %d %d",&a,&b,&c);
p1= &a;
if (b > *p1)p1= &b;
if (c > *p1)p1= &c;
p3= &a;
if (b< *p3) p3= &b;
if (c< *p3) p3= &c;
p2= &a;
if ( p2==p1 || p2==p3) p2= &b;
if ( p2==p3 || p2==p3) p2= &c;薯讓蠢
printf("%d %d %d\數陪n",*p1,*p2,*p3);
return 0;
}
⑸ c語言指針編程題求解。
#include "stdio.h"
void Sum(int (*p)[3],int total[],int n)//n是總行數
{
int i,j;
for(i=0;i<n;i++)
{
for (j=0;j<3;j++)
{
total[i]=total[i]+*(*(p+i)+j);
}
}
}
int main()
{
int a[2][3]={};
int total[2]={0,0};
int i,j;
printf("輸氏茄入數組a: ");
for(i=0;i<2;i++)
{
for (j=0;j<3;j++)
{
scanf("%d",&殲脊察a[i][j]);
}
}
Sum(a,total,2);
printf("各野脊行的和: ");
for(i=0;i<2;i++)
printf("%d ",*(total+i));
return 0;
}
⑹ 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語言指針編程題,求大佬解答
#include <stdio.h>
void myitoa(int n,char*str)
{int i,j;
char t;
for(i=0;n;i++)
{str[i]='0'+n%10;
n/=10;
}
str[i]='