#14101: 我用C寫的,,因為前天寫完a010(相似)這題,今天順道來寫這題,可供參考..P.S.這題很少人寫解題報告

#### HuangNO1 (雷姆醬)

School : 中南大学
ID : 60967
2019-07-20 11:22:35
b266. 矩陣翻轉 -- | From: [61.230.165.75] | Post Date : 2018-06-13 21:51

#include <stdio.h>
#define num 100
int s[ num ][ num ] , MM[ num ] ;
int R , C , M ;
void action_1 ()    //逆時針旋轉
{
int s_cpy[ num ][ num ] , i , j ;
for ( i = 0 ; i < R ; i ++ )
for ( j = 0 ; j < C ; j ++ )
s_cpy[ C - 1 - j ][ i ] = s[ i ][ j ] ;
int temp = R ; R = C ; C = temp ;
for ( i = 0 ; i < R ; i ++ )
for ( j = 0 ; j < C ; j ++ )
s[ i ][ j ] = s_cpy[ i ][ j ] ;
}
void action_2 ()   //上下翻轉
{
int s_cpy[ num ][ num ] , i , j ;

for ( i = 0 ; i < R ; i ++ ){
for ( j = 0 ; j < C ; j ++ )
s_cpy[ R - 1 - i ][ j ] = s[ i ][ j ] ;
}
for ( i = 0 ; i < R ; i ++ )
for ( j = 0 ; j < C ; j ++ )
s[ i ][ j ] = s_cpy[ i ][ j ] ;
}
int main()
{
int i , j ;
while ( scanf ( "%d %d %d" , &R , &C , &M ) != EOF ){
for ( i = 0 ; i < R ; i ++ )
for ( j = 0 ; j < C ; j ++ )
scanf ( " %d" , &s[ i ][ j ] ) ;
for ( i = 0 ; i < M ; i ++ )
scanf ( " %d" , &MM[ i ] ) ;
for ( i = M - 1 ; i >= 0 ; i -- ){ //指令由後往前執行(推回A)
if ( MM[ i ] == 0 )
action_1 () ;
else
action_2 () ;
}
printf ( "%d %d\n" , R , C ) ;
for ( i = 0 ; i < R ; i ++ ){
for ( j = 0 ; j < C - 1 ; j ++ )
printf ( "%d " , s[ i ][ j ] ) ;
printf ( "%d\n" , s[ i ][ C - 1 ] ) ;
}
}
return 0 ;
}

#14102: Re:我用C寫的,,因為前天寫完a010(相似)這題,今天順道來寫這題,可供參考..P.S.這題很少人寫解題報告

#### HuangNO1 (雷姆醬)

School : 中南大学
ID : 60967
2019-07-20 11:22:35
b266. 矩陣翻轉 -- | From: [61.230.165.75] | Post Date : 2018-06-13 21:56

#define 可定義 常數 or 巨集

#16262: Re:我用C寫的,,因為前天寫完a010(相似)這題,今天順道來寫這題,可供參考..P.S.這題很少人寫解題報告

#### freedom501999@gmail.com (帥氣魔方生)

School : Not Student
ID : 88611
2019-05-30 22:56:25
b266. 矩陣翻轉 -- | From: [27.52.77.116] | Post Date : 2018-12-13 16:50

ZeroJudge Forum