c語言:編程求數列3+23+223+2223+...前8項之和,咋寫

代碼文本:

#include "stdio.h"

int main(int argc,char *argv[]){

int n,s,t,i;

for(s=10,n=2;n<9;n++){

for(t=10,i=1;i<n;t*=10,i++);

s+=(t-1)/9*2;

}

printf("3+23+223+...+22222223 = %d ",s);

return 0;

}

⑵ C語言問題,求大神解決,謝謝拉。。我是小白,解釋下原因

scanf("%d%c%f",&a,&b,&c);//%d後面無空格

printf("%d %c %f ",a,b,c);

輸出2223 a 123.00000

⑶ c語言求一個數的因子

#include <stdio.h>

# include <stdlib.h>

#define N 100

long factor(int m,int fac[],int *cp){

int c1,c2,i,k;

long s;

fac[0]=1;

for(c1=s=1,c2=N-1,i=2;;){

k=m/i;

if(m%i==0){

if(i!=k){

fac[c1++]=i;

fac[c2--]=k;

s+=i+k;

printf("i=%d k=%d ",i,k);

}else{

fac[c1++]=i;

s+=i;

}

}

i++;

if(i>=k) break;//這個時候k已經開始等於自身的根號,或者將要出現和之前k對稱的i,引起自身重復故退出

}

for(c2++;c2<=N-1;c2++){

fac[c1++]=fac[c2];

printf("%s %d ","**",fac[c2]);

}

*cp=c1;

return s;

}

int main(int argc, char const *argv[])

{

/* code */

int factors[N],i,count;

long sum;

sum = factor(atoi(argv[1]),factors,&count);

for(i=0;i<count;i++){

printf("%5d",factors[i]);

}

printf(" ");

printf("sum=%5ld count=%5d ",sum,count);

return 0;

}

(3)c語言2223擴展閱讀:

有一種說法是「因子不限正負」,不過通常情況下只取正因子。

1, -1, n 和 -n 這些數叫做 n 的明顯因子

表示方法:可以用因子|倍數或倍數≡0 (mod 因子) 來表達(參見同餘),但用後者時因子一定要是正因子。因子∣倍數式中的垂直線是整除符號。它的統一碼值是 U+2223。

例如 42=6x7,因此 7 是 42 的因子,寫作 7∣42,亦是42≡0(mod 7)。



⑷ error C2223: left of '->next' must point to struct/union

你的k應該定義為結構體變數,如果你要用->,還必須是個指針變數
struct
node
*k;
申請空間也一樣
k=(struct
node*)malloc(sizeof(struct
node));
p也一樣;
你好像是吧typedef的用法弄錯了,你是不是本來想寫typedef
struct
node*
LinkedList;的

⑸ error C2223: left of '->a' must point to struct/union 如何解決錯誤,程序在下面

你想賦值?那不能用這種寫法,這樣做

#include<stdio.h>
void main()
{

float a;
a=1+2;
a=a+3;
a=a+4;
a=a+5;
a=a+6;
a=a+8;
a=a+9;
a=a+10;
printf("%f",a);
}

⑹ 用c語言求一個數的所有因子

C語言程序如下:

#include <stdio.h>

# include <stdlib.h>

#define N 100

long factor(int m,int fac[],int *cp){

int c1,c2,i,k;

long s;

fac[0]=1;

for(c1=s=1,c2=N-1,i=2;;){

k=m/i;

if(m%i==0){

if(i!=k){

fac[c1++]=i;

fac[c2--]=k;

s+=i+k;

printf("i=%d k=%d ",i,k);

}else{

fac[c1++]=i;

s+=i;

}

}

i++;

if(i>=k) break;//這個時候k已經開始等於自身的根號,或者將要出現和之前k對稱的i,引起自身重復故退出

}

for(c2++;c2<=N-1;c2++){

fac[c1++]=fac[c2];

printf("%s %d ","**",fac[c2]);

}

*cp=c1;

return s;

}

int main(int argc, char const *argv[])

{

/* code */

int factors[N],i,count;

long sum;

sum = factor(atoi(argv[1]),factors,&count);

for(i=0;i<count;i++){

printf("%5d",factors[i]);

}

printf(" ");

printf("sum=%5ld count=%5d ",sum,count);

return 0;

}

(6)c語言2223擴展閱讀:

數學概念

假如整數n除以m,結果是無余數的整數,那麼我們稱m就是n的因子。 需要注意的是,唯有被除數,除數,商皆為整數,余數為零時,此關系才成立。反過來說,稱n為m的倍數。

要留意的是:有一種說法是「因子不限正負」,不過通常情況下只取正因子。

1, -1, n 和 -n 這些數叫做 n 的明顯因子

⑺ 用c語言求一個數的所有因子

#include <stdio.h>

# include <stdlib.h>

#define N 100

long factor(int m,int fac[],int *cp){

int c1,c2,i,k;

long s;

fac[0]=1;

for(c1=s=1,c2=N-1,i=2;;){

k=m/i;

if(m%i==0){

if(i!=k){

fac[c1++]=i;

fac[c2--]=k;

s+=i+k;

printf("i=%d k=%d ",i,k);

}else{

fac[c1++]=i;

s+=i;

}

}

i++;

if(i>=k) break;//這個時候k已經開始等於自身的根號,或者將要出現和之前k對稱的i,引起自身重復故退出

}

for(c2++;c2<=N-1;c2++){

fac[c1++]=fac[c2];

printf("%s %d ","**",fac[c2]);

}

*cp=c1;

return s;

}

int main(int argc, char const *argv[])

{

/* code */

int factors[N],i,count;

long sum;

sum = factor(atoi(argv[1]),factors,&count);

for(i=0;i<count;i++){

printf("%5d",factors[i]);

}

printf(" ");

printf("sum=%5ld count=%5d ",sum,count);

return 0;

}

(7)c語言2223擴展閱讀:

有一種說法是「因子不限正負」,不過通常情況下只取正因子。

1, -1, n 和 -n 這些數叫做 n 的明顯因子

表示方法:可以用因子|倍數或倍數≡0 (mod 因子) 來表達(參見同餘),但用後者時因子一定要是正因子。因子∣倍數式中的垂直線是整除符號。它的統一碼值是 U+2223。

例如 42=6x7,因此 7 是 42 的因子,寫作 7∣42,亦是42≡0(mod 7)。



⑻ c語言輸出二十五宮格代碼

用拉伊爾法製造五階幻方(25宮格)
第一步:構造基方:用1-5填寫幻方,使兩回對角線上分別答是12345和33333,而且每橫行縱行和均為15,如下
1 4 2 5 3
4 2 5 3 1
2 5 3 1 4
5 3 1 4 2
3 1 4 2 5
第二步:然後構造根方:將基方左右調轉過來,每個數都減去1,再乘以5,得到如下
10 20 5 15 0
0 10 20 5 15
15 0 10 20 5
5 15 0 10 20
20 5 15 0 10
第三步:根方和基方每個對應小格中的數相加,得到最後的幻方
11 24 7 20 3
4 12 25 8 16
17 5 13 21 9
10 18 1 14 22
23 6 19 2 15
即二十五宮格。

⑼ c語言問題,和結構體有關

NULL在系統中有定義無需自己定義。
struct student *p1,*p2,*head;//你忘記定義後面的head要定義
struct student.subject math;//這句好像沒有用。
scanf("%f",&p1->subject.math); //subject.math 改為.指針才用-> /*到這里讓p1指向第一組數據結束*/
int n=n+1; //你忘記定義n了
scanf("%f",&p1->subject.math);//subject.math 改為.指針才用->
你試試看還有什麼問題