Postgraduate review machine questions (2010)
Reprinted please indicate the source: dunni column http://blog.csdn.net/u012027907
Answer:
/** Description: machine question a answer * Author: Zhang yachao * blog: dunny column http://blog.csdn.net/u012027907 * Date: */# include "stdio. H "# define Max 1000int getevesum (INT num) {// calculate the numbers and INT sum = 0; while (num! = 0) {int r = num % 10; num = num/10; sum + = r;} return sum;} void sort (INT store [], int count) {// bubble sort for (INT I = 0; I <count; I ++) for (Int J = I + 1; j <count; j ++) {If (store [I]> store [J]) {int temp = store [I]; store [I] = store [J]; store [J] = temp ;}}void print (INT store [], int count) {// print the output for (INT I = 0; I <count; I ++) printf ("% d", store [I]); printf ("\ n") ;}int main () {int store [Max]; int COUNT = 0; int num; scanf ( "% D", & num); While (num! = 0) {store [count ++] = getevesum (Num); scanf ("% d", & num) ;}sort (store, count); print (store, count); Return 0 ;}
Answer:
/** Description: Machine questions B answers * Author: Zhang yachao * blog: dunny column http://blog.csdn.net/u012027907 * Date: */# include <stdio. h> # define M 100 # define n 100 void maanpoint (INT matrix [] [N], int M, int N) {bool isexist = false; int min, JJ, Max, II; For (INT I = 0; I <m; I ++) {// traverse a row by min = matrix [I] [0]; JJ = 0; for (int d = 0; D <n; D ++) {// find the minimum value of each row and Its subscript if (Matrix [I] [d] <min) {min = matrix [I] [d]; JJ = D ;}} max = matrix [0] [JJ]; II = 0; (Int A = 0; A <m; A ++) {// find the maximum value of each column and Its subscript if (Matrix [a] [JJ]> MAX) {max = matrix [a] [JJ]; II = A ;}} if (max = min) {// equal, isexist = true at the saddle point; printf ("% d \ n", II, JJ, max) ;}} if (! Isexist) {// The Saddle Point printf ("NO \ n") ;}} int main () {int matrix [m] [N]; int M, N; scanf ("% d", & M, & N); For (INT I = 0; I <m; I ++) for (Int J = 0; j <n; j ++) {scanf ("% d", & matrix [I] [J]);} maanpoint (matrix, m, n); Return 0 ;}
Reprinted please indicate the source: dunni column http://blog.csdn.net/u012027907
Postgraduate review machine questions (2010)