数组,循环,条件23

//找数组的最大值和最小值,将数组转换
#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(){
 int arr [2][3];
 int arr2[3][2];
 int max, min;
 int i, j;
 int h;
 int l;
 for (i = 0; i < 2; i++){
  for (j = 0; j < 3; j++){
   printf("arr[%d][%d]=",i,j);
   scanf("%d", &arr[i][j]);
  }
 }
 printf("输出二维数组:\n");
 for (i = 0; i < 2; i++){
  for (j = 0; j < 3; j++){
   printf("%d ", arr[i][j]);
  }
  putchar('\n');
 }
 max = arr[0][0];
 h = 0;
 l = 0;
 for (i = 0; i < 2; i++){
  for (j = 0; j < 3; j++){
   if (max < arr[i][j]){
    max = arr[i][j];
    h = i;
    l = j;
   }
  }
 }
 printf("数组中最大的原数数:\n");
 printf("max=%d\n", max);
 min = arr[0][0];
 for (i = 0; i < 2; i++){
  for (j = 0; j < 3; j++){
   if (min>arr[i][j]){
    min = arr[i][j];
   }
  }
 }
 printf("数组中最小的原属是:\n");
 printf("min=%d\n", min);
 for (i = 0; i < 2; i++){
  for (j = 0; j < 3; j++){
   arr2[j][i] = arr[i][j];
  }
 }
 printf("输出二维数组:\n");
 for (i = 0; i < 3; i++){
  for (j = 0; j < 2; j++){
   printf("%d\t",arr2[i][j]);
  }
  putchar('\n');
 }
 system("pause");
 return 0;
}

*#include<stdio.h>
int main(){//定义一个变量进行自增自减
 int a = 6;
 int x1, x2, x3, x4;
   x1 = ++a;
  x2 = a++;
  x3 = --a;
  x4 = a--;
 printf("%d\n%d\n%d\n%d\n", x1, x2, x3, x4);
 system("pause");
 return 0;
}*/

*#include<stdio.h>
int main(){
 char *Char = "i love chine";
 puts("i love chine");
 puts(Char);
 Char = "i love chine";
 puts(Char);
 system("pause");
 return 0;
}*/
/*#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(){
 char a;
 char b;
 puts("请输入一个字母");
 scanf("%c", &a);
 b = a - 32;
 printf("b=%c\n", b);//大写字母
 printf("%d\n", b);//ASCII中的位置
 system("pause");
 return 0;
}*/
#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main(){
 int num;
 int yue = 2000;
 int shang;
 int ti;
 printf("请输入你的商品数:");
 scanf("%d", &shang);
 ti = shang * 15;
 num =2000 + ti;
  printf("num = %d\n", num);
  system("pause");
 return 0;
}
#define  _CRT_SECURE_NO_WARNINGS//条件语句的练习
#include<stdio.h>
#include<stdlib.h>
int main(){
 int x=0,i;
 int y;
 printf("%d\n", x);
 scanf("%d",&x);
 if(x < 1){
  i = 1;
 }
 else if (x >= 1 && x < 10){
  i = 2;
 }
 else
  i = 3;
 switch (i){
 case 1:
  y = x;
  break;
 case 2:
  y = 2 * x - 1;
  break;
 case 3:
  y = 2 * x - 11;
  break;
 }
 printf("y=%d\n", y);
 system("pause");
 return 0;
}
int main(){
 int x, y, z;
 int max;
 printf("input x,y,z\n");
 scanf("%d %d %d", &x, &y, &z);
 if (x < y){
  max = y;
 }
 else {
  max = x;
 }
 if (max>z){
  printf("%d\n", max);
 }
 else
  max = z;
 printf("%d\n", max);
 system("pause");
 return 0;
}
//循环控制课后题
//输出0-100不能被三整除的数
#include<stdio.h>
#include<stdlib.h>
int main(){
 int i;
 for (i = 0; i <= 100; i++){
  if (i % 3 != 0){
   printf("i=%d\n", i);
  }
 }
 system("pause");
 return 0;
}
#include<stdio.h>
#include<stdlib.h>//使用for循环打印大写字母对应的ASCII码
int main(){
 int i;
 for (i = 0; i < 26; i=i+2){
  printf("字母 %c 对应的ASCII码为 %d  │  ", i + 65, i + 65);
  printf("字母 %c 对应的ASCII码为 %d \n", i + 66, i + 66);
 }
 system("pause");
 return 0;
}

猜你喜欢

转载自www.cnblogs.com/yuzhenghan/p/12006803.html