标签:not found blog std print can span main pre after
#include<stdio.h> int main() { int i; double average,sum=0; int a[10]; printf("请输入十个同学的成绩:"); for(i=0;i<10;i++){ scanf("%d",&a[i]); sum=sum+a[i]; } average=sum/10; printf("average=%.2f\n",average); printf("sum=%.2f\n",sum); return 0; }
#include<stdio.h> int main() { int i,x,flag; int a[5]; printf("请输入五个整数:"); for(i=0;i<5;i++) scanf("%d",&a[i]); printf("请输入一个整数x:"); scanf("%d",&x); flag=0; for(i=0;i<5;i++); if(a[i]==x) { printf("Index is %d\n",i); flag=1; break; } if(flag==0) printf("Not found\n"); return 0; }
#include<stdio.h> int main() { int n,i,index; int a[10]; printf("请输入n(1<n≤10):"); scanf("%d",&n); printf("请输入%d个数:",n); for(i=0;i<n;i++) scanf("%d",&a[i]); index=0; for(i=0;i<n;i++) if(a[i]>a[index]) index=i; printf("max is %d \ tsub is %d \n",a[index],index); return 0; }
#include<stdio.h> int main() { int i,index,k,n,temp; int a[10]; printf("请输入一个正整数n(1<n≤10):"); scanf("%d",&n); printf("请输入%d个数:",n); for(i=0;i<n;i++) scanf("%d",&a[i]); for(k=0;k<n-1;k++){ index=k; for(i=k+1;i<n;i++) if(a[i]>a[index]) index=i; temp=a[index]; a[index]=a[k]; a[k]=temp; } printf("After sorted: "); for(i=0;i<n;i++) printf("%5d",a[i]); return 0; }
标签:not found blog std print can span main pre after
原文地址:http://www.cnblogs.com/cs-16-4-zlt/p/6067760.html