个人感觉用指针比较简单 include <iostream> using namespace std;int main(){ int i;int num1[10],num2[10];int *p1,*p2;p1=num1;p2=num2;//指针初始化;cout<<"please enter 10 numbers:\n";for(i=0;i<10;i++){cin>>num[i];num2[i]=' ';}//初始化数组2 for(i=0;i<...
代码如下:include <stdio.h>#include <stdlib.h>int main(){int numbers[10];// 输出数据printf("请输入10个整数:");for (int i = 0; i < 10; i++)scanf("%d", &numbers[i]);// 处理数据for (int i = 0; i < 10; i++) {if (numbers[i] % 2 == 0) {for (int j...
include<stdio.h>int main() {int i,n = 10,a[10] = {0};for(i = 0; i < n; ++i) scanf("%d",&a[i]);for(i = 1; i < n;i += 2) printf("%d ",a[i]);printf("\n");return 0;}
cout<<"给我10个整数:"<<endl;int n[10];int numOfEven=0; //偶数个数 int numOfOdd=0; //奇数个数 for(int i=0;i<10;i++){ cin>>n[i]; //输入数组 if(n[i]%2) numOfOdd++;else numOfEven++;} cout<<"奇数有"<<numOfOdd<<"个"<<endl;cout<<"偶数有...
输入10个数,将10个整数按升序排列输出,并且奇数在前,偶数在后。如果输入的10个数是:10 9 8 7 6 5 4 3 2 1 ,则输出:1 3 5 7 9 2 4 6 8 10。(编程提示:可利用2个数组变量,一个用来存放输入的整数,输入后,对这个数组进行排序,然后将数据复制到另一个数组中,先复制奇数再复制偶数)。
include <stdio.h>int main(){int i,a[10],x,y;x=y=0;for(i=0;i<10;i++){scanf("%d",&a[i]);if(a[i]%2) x++;else y++;}printf("奇数有:%d,偶数有:%d\n",x,y); return 0;}
include <stdio.h> void main(){ int *n=new int [10];printf("输入10个数字:");for (int i=0;i<10;i++){ scanf("%d",&n[i]);} for ( i=0;i<10;i++){ if(i%2==0) printf("%d\t",n[i]);} printf("\n");} ...
int main(){int i,a[10];printf("请输入10个整数:\n");for(i=0;i<10;i++)scanf("%d",&a[i]);for(i=1;i<9;i+=2)printf("%d,",a[i]);printf("%d ",a[i]);for(i=0;i<10;i+=2)printf("%d,",a[i]);printf("%d\n",a[i]);for(i=0;i<9;i++)printf(...
用visual c++编写:include<stdio.h> int main(){ int a[10],i,j,sum;for(j=0;j<=9;j++){ printf("a[%d]=",j+1);scanf("%d",&a[j]);} sum=a[0]+a[2]+a[4]+a[6]+a[8];printf("sum=%d\n",sum);return 0;} ...
include<stdio.h>int main(void){int i,t=0,m=0,s[10];for(i=0;i<10;i++)scanf("%d",&s[i]);for(i=0;i<10;i++){ if(s[i]%2==0) t++;}printf("输出偶数是:%d\n",t);for(i=0;i<10;i++){ if(s[i]%2!=0) m++;}printf("输出奇数是:%d\n"...