Ⅰ 編寫c語言程序 列印圖形
*
***
*****
*******
你先看一下圖形有什麼特點
我替你回答,特點是每一行都是奇數
它們可以用一個公式來表達
星星數=2*行數-1
定義星星數為k,行數為i
k=2*i-1
然後就能寫程序了
main()
{
int i,j,k;
for(i=1;i<=5;i++)
{
k=2*i-1;
for(j=0;j<k;j++)
printf("*");
printf("\n");
}
}
Ⅱ c語言編程 列印圖形,菜單包括:矩形,平行四邊形,輸入圖形的行數、列數並輸入列印的字元,列印出圖形
#include<stdio.h>
#define true 1
void print(char cType, int iRow, int iColumn, char cMark)
{
int i,j;
if(cType == 'A')
{
for(i = 0; i < iRow; i++)
{
for(j = 0; j < iColumn; j++)
{
printf("%c ", cMark);
}
printf("\n");
}
}
else if(cType == 'B')
{
for(i = 0; i < iRow; i++)
{
for(j = iRow; j > i; j--)
{
printf(" ");
}
for(j = 0; j < iColumn; j++)
{
printf("%c ", cMark);
}
printf("\n");
}
}
else
{
printf("Error\n");
}
}
int main()
{
int iRow;
int iColumn;
char cType;
char cMark;
while(true)
{
printf("Please select the graph you want to print \nA. Rectangle B. Parallelogram Q. Quit\n");
scanf("%c", &cType);
getchar();
if(cType != 'A' && cType != 'B' && cType != 'Q')
{
printf("\nInput illegal\n\n");
continue;
}
if(cType == 'Q')
{
return 0;
}
printf("Please input the number of rows: ");
scanf("%d", &iRow);
printf("Please input the number of columns: ");
scanf("%d", &iColumn);
printf("Please input the charactor you want to print : ");
getchar();
scanf("%c", &cMark);
getchar();
print(cType, iRow, iColumn, cMark);
}
return 0;
}
Ⅲ C語言用循環列印列印圖形
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int i, j, delta;
/* delta為是否輸出'*' */
for (i = 1; i <= 14; ++i) { /* 總共有14行 */
/* 輸出每行開頭空格 */
for (j = 1; j < i; ++j)
printf(" ");
/* 輸出每行字元 */
delta = 0; /* 還沒有輸出'*' */
for (j = i; j <= 28 - i; ++j) {
if (j == 14) {
printf("*");
delta = 1; /* 已經輸出'*' */
}
else
printf("%c", 'A' + j - 1 - delta); /* 輸出英文字元 */
}
/* 每行換行 */
printf("\n");
}
system("pause"); /* 暫停 */
return 0;
}
Ⅳ c語言編程(列印圖形)
#include<stdio.h>
void main()
{
int n,i,j;
printf("輸入n:\n");
scanf("%d",&n);
printf("****\n");
for(i=1;i<=n-1;i++)
{
for(j=1;j<=i;j++)
printf(" ");
printf("****");
printf("\n");
}
}
Ⅳ C語言編程列印下列圖形AAAAABBBBBCCCCCDDDDD
main()
{
printf("AAAAA ");
printf("BBBBB ");
printf("CCCCC ");
printf("DDDDD ");
}
這是思路最傻的了。。
下面這個改了下
#include<stdio.h>
#include<string.h>
main()
{
charc='A';
intn;
inti;
intj;
printf("請輸入需要列印的行數: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf("");
}
for(j=1;j<=4;j++)
{
printf("%c",c);
}
printf(" ");
c++;
}
}
Ⅵ C語言列印圖案的原理,麻煩詳細解釋,最好有配圖和文字解說,本人大一,正在困惑中
列印圖案有多種。
一、有規律的圖形,比如正方形,菱形,圓 ......等等。這些都可以找圖形規律(比如菱形上半部分依次下層比上層多2個字元),再通過簡單的參數循環,用單一字元列印出來(printf就可以了)。這種比較簡單,網上也有很多現成的代碼可以參考,比如:【引用】c語言列印規則圖形
二、復雜的圖像,比如一張照片,可以寫代碼把圖片轉換成2值圖(2值圖就是把圖片中每個像素用0或1數字矩陣來表示)然後再列印轉換後的01矩陣,這個比較復雜,網上也有很多現成的轉2值圖代碼。【引用】圖片二值化程序
當然你也可以直接用網上工具把圖片轉換成字元圖(就是貼吧里經常用的那種字元組成的圖案),然後保存到文件中,c語言寫讀取文件列印。(或者直接把字元全部賦值到printf中列印,但這樣就沒啥意思了)。【引用】在線圖片轉字元畫
Ⅶ 用C語言列印如下圖形 ********** ********* ******** ******* ****** ***** **** *** ** *
#include<stdio.h>
void main()
{
int i,j;
for(i=1;i<=10;i++)
{
for(j=11-i;j>=1;j--)
printf("*");
printf("\n");
}
}
效果:
**********
*********
********
*******
******
*****
****
***
**
*
Ⅷ 很急啊...C語言列印圖形
你可以這樣來寫:
#include <stdio.h>
int main(void)
{
int n = 5, line = 1;
while(n-- > 0){
switch(line){
case 2: printf("一個空格"); break;
case 3: printf("兩個空格"); break;
case 4: printf("三個空格"); break;
case 5: printf("四個空格"); break;
}
printf("****************\n");
line++;
}
return 0;
}
由於網路限制了空格,所上面有漢字說明.
Ⅸ C語言編程問題,關於列印各種圖形的規律 請教大神 20分送上
三種方法,但前提是無需列印另建一層......點擊看詳細的,不需要關閉列印層......
二,該層並不需要列印凍結......點擊看詳細3,點擊圖標,打開圖層特性管理器,將不需要列印後面的一層列印功能關閉,單擊小圖標變成這樣,它可以將列印機......點擊看詳細如有不明白,我可以Q ......
Ⅹ C語言列印數字圖形
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
for(j=i-1;j>=1;j--)
printf("%d",j);
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(j=1;j<=n-i;j++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
for(j=i-1;j>=1;j--)
printf("%d",j);
printf("\n");
}
return 0;
}