c語言列列印
A. 如何用c語言列印出二維數組
假設需要列印的數組為int類型,數組名為Array,Dim1為數組的行,Dim2為數組的列。
inti,j;//臨時變數
for(i=0;i<Dim1;i++)//外層循環遍歷行
鏈余for(j=0;j<Dim2;j++)//內層循環遍歷列
{
printf("%d",Array[i][j]);//訪問數組元素並列印
}
B. C語言列印出n行n列的圖形,第一列一個*,第二列兩個**,第三列三個***,直到n列n個*,列與列有一空格
#include<stdio.h>雹正判
#include<stdlib.h>
#defineN10
intmain()
{
inti;
int清襪j;
for(i=0;i<N;i++)
{
for(j=0;j<=i;j++)
printf("*");
源改printf(" ");
}
}
C. C語言列印方格
#include <stdio.h>
int main()
{
int t;
int l[10];
int c[10];
int i,line,col;
scanf("%d", &t);
if (t > 0 && t < 10)
{
for (i = 0;i < t;i++)
{
scanf("%d %d", &l[i], &c[i]);
}
for (i = 0;i <高蔽世 t;i++)
{
/並蘆/每組i開始的*
printf("-");
for (col = 0;col < c[i];col++)
{
printf("---");
}
printf("\n");
//1行1列列印
for (line = 0;line < l[i];line++)
{
printf("|");
for (col = 0;col < c[i];col++)
{
printf(" |");
}
printf("\n");
printf("|");
for (col = 0;col < c[i];col++)
{
printf(" |");
}
printf("戚肢\n");
printf("-");
for (col = 0;col < c[i];col++)
{
printf("---");
}
printf("\n");
}
}
}
return 0;
}
D. c語言 列印給定字元串的所有排列
#include <stdio.h>
void pern(char s[],int k)
{int i;
char c;
if(k==2)
printf("%s ",s);
else
for(i=k;i<=2;i++)
{c=s[k];s[k]=s[i];s[i]=c;
pern(s,k+1);
c=s[k];s[k]=s[i];s[i]=c;
}
}
void print_all_permutations(char *str)
{ pern(str,0);
return;
}
int main(void)
{ char str[256] = "ABC";
print_all_permutations(str);
return 0;
}
E. C語言如何把結果按列輸出呀
#include<stdio.h>
intmain()
{
inti,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)printf("%d×%d=%-2d",j,i,i*j);
puts("");//<-----------在這里列印一個空行,也就是換行符。
}
return0;
}
F. c語言隊列輸出列印問題
要學會調試啊,你一調蔽悄試就會發現你的隊列頭是一個回車,然後擾並枯你就知道,你緩洞有回車沒處理
G. C語言:設計一個函數chline(ch,i,j),列印指定的字元j行i列。我這樣
#include<stdio.h>
void chline(char ch,int i,int j)
{int i1,j1;
for(i1=0;i1<i;i1++)
{for(j1=0;j1<j;j1++)
printf("%c",ch);
printf(" ");
}
}
int main()
{char ch;
int i,j;
printf("Input ch i j:");
升擾李scanf("%c%d%d",&ch,&吵遲i,&j);
李手chline(ch,i,j);
return 0;
}
H. C語言怎麼並列列印兩個的二維數組
#include<stdio.h>
intmain()
{ inta[3][3]={1,2,3,4,5,6,7,8,9},b[3][3]={10,20,30,40,50,60,70,80,90};
inti,j;
printf("%-13s%-10s ","余歲A數組:","B數豎辯睜組灶漏:");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%3d",a[i][j]);
printf("");
for(j=0;j<3;j++)
printf("%3d",b[i][j]);
printf(" ");
}
return0;
}